
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>08 服务器端file_server源码分析 · 高性能服务器开发 技术专栏</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="easy_coder">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-fexa/fexa.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="09服务器端route_server源码分析.html" />
    
    
    <link rel="prev" href="07服务器端msfs源码分析.html" />
    

    </head>
    <body>
        
<div class="book">
	<div class="header-inner">
		<!-- LOGO -->
		<div class="logo"></div>
		<span class="title"></span>

		<!-- Search -->
		
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>


		<!-- Nav -->
		<ul class="header-nav">
			
		</ul>
	</div>

	<div class="book-summary">
		<div class="book-summary-title">文档目录</div>
		
		
		<nav role="navigation">
			


<ul class="summary">
    
    

    

    
        
        <li class="header">Part I</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../C++必知必会的知识点/">
            
                <a href="../C++必知必会的知识点/">
            
                    
                    C++必知必会的知识点
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../C++必知必会的知识点/如何成为一名合格的CC++开发者？.html">
            
                <a href="../C++必知必会的知识点/如何成为一名合格的CC++开发者？.html">
            
                    
                    如何成为一名合格的C/C++开发者？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../C++必知必会的知识点/不定参数函数实现var_arg系列的宏.html">
            
                <a href="../C++必知必会的知识点/不定参数函数实现var_arg系列的宏.html">
            
                    
                    不定参数函数实现var_arg系列的宏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../C++必知必会的知识点/你一定要搞明白的C函数调用方式与栈原理.html">
            
                <a href="../C++必知必会的知识点/你一定要搞明白的C函数调用方式与栈原理.html">
            
                    
                    你一定要搞明白的C函数调用方式与栈原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../C++必知必会的知识点/深入理解CC++中的指针.html">
            
                <a href="../C++必知必会的知识点/深入理解CC++中的指针.html">
            
                    
                    深入理解C/C++中的指针
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../C++必知必会的知识点/详解C++11中的智能指针.html">
            
                <a href="../C++必知必会的知识点/详解C++11中的智能指针.html">
            
                    
                    详解C++11中的智能指针
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../C++必知必会的知识点/C++17结构化绑定.html">
            
                <a href="../C++必知必会的知识点/C++17结构化绑定.html">
            
                    
                    C++17结构化绑定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../C++必知必会的知识点/C++必须掌握的pimpl惯用法.html">
            
                <a href="../C++必知必会的知识点/C++必须掌握的pimpl惯用法.html">
            
                    
                    C++必须掌握的pimpl惯用法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../C++必知必会的知识点/用VisualStudio调试Linux程序.html">
            
                <a href="../C++必知必会的知识点/用VisualStudio调试Linux程序.html">
            
                    
                    用Visual Studio调试Linux程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../C++必知必会的知识点/如何使用VisualStudio管理和阅读开源项目代码.html">
            
                <a href="../C++必知必会的知识点/如何使用VisualStudio管理和阅读开源项目代码.html">
            
                    
                    如何使用Visual Studio管理和阅读开源项目代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10" data-path="../C++必知必会的知识点/利用cmake工具生成VisualStudio工程文件.html">
            
                <a href="../C++必知必会的知识点/利用cmake工具生成VisualStudio工程文件.html">
            
                    
                    利用cmake工具生成Visual Studio工程文件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../多线程/">
            
                <a href="../多线程/">
            
                    
                    多线程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../多线程/后台C++开发你一定要知道的条件变量.html">
            
                <a href="../多线程/后台C++开发你一定要知道的条件变量.html">
            
                    
                    后台C++开发你一定要知道的条件变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../多线程/整型变量赋值是原子操作吗？.html">
            
                <a href="../多线程/整型变量赋值是原子操作吗？.html">
            
                    
                    整型变量赋值是原子操作吗？
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../网络编程/">
            
                <a href="../网络编程/">
            
                    
                    网络编程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="../网络编程/bind函数重难点解析.html">
            
                <a href="../网络编程/bind函数重难点解析.html">
            
                    
                    bind 函数重难点解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="../网络编程/connect函数在阻塞和非阻塞模式下的行为.html">
            
                <a href="../网络编程/connect函数在阻塞和非阻塞模式下的行为.html">
            
                    
                    connect 函数在阻塞和非阻塞模式下的行为
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="../网络编程/select函数重难点解析.html">
            
                <a href="../网络编程/select函数重难点解析.html">
            
                    
                    select 函数重难点解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="../网络编程/Linuxepoll模型（含LT模式和ET模式详解）.html">
            
                <a href="../网络编程/Linuxepoll模型（含LT模式和ET模式详解）.html">
            
                    
                    Linux epoll 模型（含LT 模式和 ET 模式详解）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5" data-path="../网络编程/socket的阻塞模式和非阻塞模式.html">
            
                <a href="../网络编程/socket的阻塞模式和非阻塞模式.html">
            
                    
                    socket 的阻塞模式和非阻塞模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.6" data-path="../网络编程/非阻塞模式下send和recv函数的返回值.html">
            
                <a href="../网络编程/非阻塞模式下send和recv函数的返回值.html">
            
                    
                    非阻塞模式下 send 和 recv 函数的返回值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7" data-path="../网络编程/服务器开发通信协议设计介绍.html">
            
                <a href="../网络编程/服务器开发通信协议设计介绍.html">
            
                    
                    服务器开发通信协议设计介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.8" data-path="../网络编程/TCP协议如何解决粘包、半包问题.html">
            
                <a href="../网络编程/TCP协议如何解决粘包、半包问题.html">
            
                    
                    TCP 协议如何解决粘包、半包问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.9" data-path="../网络编程/网络通信中收发数据的正确姿势.html">
            
                <a href="../网络编程/网络通信中收发数据的正确姿势.html">
            
                    
                    网络通信中收发数据的正确姿势
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.10" data-path="../网络编程/服务器端发数据时，如果对端一直不收，怎么办？.html">
            
                <a href="../网络编程/服务器端发数据时，如果对端一直不收，怎么办？.html">
            
                    
                    服务器端发数据时，如果对端一直不收，怎么办？
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../程序员必知必会的网络命令/">
            
                <a href="../程序员必知必会的网络命令/">
            
                    
                    程序员必知必会的网络命令
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../程序员必知必会的网络命令/利用telnet命令发电子邮件.html">
            
                <a href="../程序员必知必会的网络命令/利用telnet命令发电子邮件.html">
            
                    
                    利用telnet命令发电子邮件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../程序员必知必会的网络命令/做Java或者C++开发都应该知道的lsof命令.html">
            
                <a href="../程序员必知必会的网络命令/做Java或者C++开发都应该知道的lsof命令.html">
            
                    
                    做Java或者C++开发都应该知道的lsof命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../程序员必知必会的网络命令/Linux网络故障排查的瑞士军刀.html">
            
                <a href="../程序员必知必会的网络命令/Linux网络故障排查的瑞士军刀.html">
            
                    
                    Linux网络故障排查的瑞士军刀nc命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.4" data-path="../程序员必知必会的网络命令/Linuxtcpdump使用介绍.html">
            
                <a href="../程序员必知必会的网络命令/Linuxtcpdump使用介绍.html">
            
                    
                    Linux tcpdump使用详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.5" data-path="../程序员必知必会的网络命令/从抓包的角度分析connect函数的连接过程.html">
            
                <a href="../程序员必知必会的网络命令/从抓包的角度分析connect函数的连接过程.html">
            
                    
                    从抓包的角度分析connect函数的连接过程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.6" data-path="../程序员必知必会的网络命令/服务器开发中网络数据分析与故障排查经验漫谈.html">
            
                <a href="../程序员必知必会的网络命令/服务器开发中网络数据分析与故障排查经验漫谈.html">
            
                    
                    服务器开发中网络数据分析与故障排查经验漫谈
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">Part II</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../高性能服务器框架设计/">
            
                <a href="../高性能服务器框架设计/">
            
                    
                    高性能服务器框架设计
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../高性能服务器框架设计/主线程与工作线程的分工.html">
            
                <a href="../高性能服务器框架设计/主线程与工作线程的分工.html">
            
                    
                    主线程与工作线程的分工
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../高性能服务器框架设计/Reactor模式.html">
            
                <a href="../高性能服务器框架设计/Reactor模式.html">
            
                    
                    Reactor模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="../高性能服务器框架设计/实例：一个服务器程序的架构介绍.html">
            
                <a href="../高性能服务器框架设计/实例：一个服务器程序的架构介绍.html">
            
                    
                    实例：一个服务器程序的架构介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="../高性能服务器框架设计/错误码系统的设计.html">
            
                <a href="../高性能服务器框架设计/错误码系统的设计.html">
            
                    
                    错误码系统的设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="../高性能服务器框架设计/日志系统的设计.html">
            
                <a href="../高性能服务器框架设计/日志系统的设计.html">
            
                    
                    日志系统的设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.6" data-path="../高性能服务器框架设计/如何设计断线自动重连机制.html">
            
                <a href="../高性能服务器框架设计/如何设计断线自动重连机制.html">
            
                    
                    如何设计断线自动重连机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.7" data-path="../高性能服务器框架设计/心跳包机制设计详解.html">
            
                <a href="../高性能服务器框架设计/心跳包机制设计详解.html">
            
                    
                    心跳包机制设计详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.8" data-path="../高性能服务器框架设计/业务数据处理一定要单独开线程吗.html">
            
                <a href="../高性能服务器框架设计/业务数据处理一定要单独开线程吗.html">
            
                    
                    业务数据处理一定要单独开线程吗
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.9" data-path="../高性能服务器框架设计/C++高性能服务器网络框架设计细节.html">
            
                <a href="../高性能服务器框架设计/C++高性能服务器网络框架设计细节.html">
            
                    
                    C++ 高性能服务器网络框架设计细节
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../服务器开发案例实战/">
            
                <a href="../服务器开发案例实战/">
            
                    
                    服务器开发案例实战
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1.1" data-path="../服务器开发案例实战/从零实现一个http服务器.html">
            
                <a href="../服务器开发案例实战/从零实现一个http服务器.html">
            
                    
                    从零实现一个http服务器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.1.2" data-path="../服务器开发案例实战/从零实现一款12306刷票软件.html">
            
                <a href="../服务器开发案例实战/从零实现一款12306刷票软件.html">
            
                    
                    从零实现一款12306刷票软件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.1.3" data-path="../服务器开发案例实战/从零实现一个邮件收发客户端.html">
            
                <a href="../服务器开发案例实战/从零实现一个邮件收发客户端.html">
            
                    
                    从零实现一个邮件收发客户端
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.1.4" data-path="../服务器开发案例实战/从零开发一个WebSocket服务器.html">
            
                <a href="../服务器开发案例实战/从零开发一个WebSocket服务器.html">
            
                    
                    从零开发一个WebSocket服务器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.1.5" data-path="../服务器开发案例实战/1从一款多人联机实时对战游戏开始.html">
            
                <a href="../服务器开发案例实战/1从一款多人联机实时对战游戏开始.html">
            
                    
                    从零学习开源项目系列（一） 从一款多人联机实时对战游戏开始
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.1.6" data-path="../服务器开发案例实战/2最后一战概况.html">
            
                <a href="../服务器开发案例实战/2最后一战概况.html">
            
                    
                    从零学习开源项目系列（二） 最后一战概况
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.1.7" data-path="../服务器开发案例实战/3CSBattleMgr服务源码研究.html">
            
                <a href="../服务器开发案例实战/3CSBattleMgr服务源码研究.html">
            
                    
                    从零学习开源项目系列（三） CSBattleMgr服务源码研究
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.1.8" data-path="../服务器开发案例实战/4LogServer源码探究.html">
            
                <a href="../服务器开发案例实战/4LogServer源码探究.html">
            
                    
                    从零学习开源项目系列（四）LogServer源码探究
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">Part III</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="./">
            
                <a href="./">
            
                    
                    TeamTalk IM源码分析
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1.1" data-path="01TeamTalk介绍.html">
            
                <a href="01TeamTalk介绍.html">
            
                    
                    01 TeamTalk介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.1.2" data-path="02服务器端的程序的编译与部署.html">
            
                <a href="02服务器端的程序的编译与部署.html">
            
                    
                    02 服务器端的程序的编译与部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.1.3" data-path="03服务器端的程序架构介绍.html">
            
                <a href="03服务器端的程序架构介绍.html">
            
                    
                    03 服务器端的程序架构介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.1.4" data-path="04服务器端db_proxy_server源码分析.html">
            
                <a href="04服务器端db_proxy_server源码分析.html">
            
                    
                    04 服务器端db_proxy_server源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.1.5" data-path="05服务器端msg_server源码分析.html">
            
                <a href="05服务器端msg_server源码分析.html">
            
                    
                    05 服务器端msg_server源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.1.6" data-path="06服务器端login_server源码分析.html">
            
                <a href="06服务器端login_server源码分析.html">
            
                    
                    06 服务器端login_server源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.1.7" data-path="07服务器端msfs源码分析.html">
            
                <a href="07服务器端msfs源码分析.html">
            
                    
                    07 服务器端msfs源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="6.1.8" data-path="08服务器端file_server源码分析.html">
            
                <a href="08服务器端file_server源码分析.html">
            
                    
                    08 服务器端file_server源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.1.9" data-path="09服务器端route_server源码分析.html">
            
                <a href="09服务器端route_server源码分析.html">
            
                    
                    09 服务器端route_server源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.1.10" data-path="10开放一个TeamTalk测试服务器地址和几个测试账号.html">
            
                <a href="10开放一个TeamTalk测试服务器地址和几个测试账号.html">
            
                    
                    10 开放一个TeamTalk测试服务器地址和几个测试账号
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.1.11" data-path="11pc客户端源码分析.html">
            
                <a href="11pc客户端源码分析.html">
            
                    
                    11 pc客户端源码分析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../libevent源码深度剖析/">
            
                <a href="../libevent源码深度剖析/">
            
                    
                    libevent源码深度剖析
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1.1" data-path="../libevent源码深度剖析/libevent源码深度剖析01.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析01.html">
            
                    
                    libevent源码深度剖析01
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.2" data-path="../libevent源码深度剖析/libevent源码深度剖析02.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析02.html">
            
                    
                    libevent源码深度剖析02
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.3" data-path="../libevent源码深度剖析/libevent源码深度剖析03.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析03.html">
            
                    
                    libevent源码深度剖析03
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.4" data-path="../libevent源码深度剖析/libevent源码深度剖析04.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析04.html">
            
                    
                    libevent源码深度剖析04
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.5" data-path="../libevent源码深度剖析/libevent源码深度剖析05.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析05.html">
            
                    
                    libevent源码深度剖析05
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.6" data-path="../libevent源码深度剖析/libevent源码深度剖析06.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析06.html">
            
                    
                    libevent源码深度剖析06
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.7" data-path="../libevent源码深度剖析/libevent源码深度剖析07.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析07.html">
            
                    
                    libevent源码深度剖析07
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.8" data-path="../libevent源码深度剖析/libevent源码深度剖析08.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析08.html">
            
                    
                    libevent源码深度剖析08
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.9" data-path="../libevent源码深度剖析/libevent源码深度剖析09.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析09.html">
            
                    
                    libevent源码深度剖析09
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.10" data-path="../libevent源码深度剖析/libevent源码深度剖析10.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析10.html">
            
                    
                    libevent源码深度剖析10
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.11" data-path="../libevent源码深度剖析/libevent源码深度剖析11.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析11.html">
            
                    
                    libevent源码深度剖析11
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.12" data-path="../libevent源码深度剖析/libevent源码深度剖析12.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析12.html">
            
                    
                    libevent源码深度剖析12
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.1.13" data-path="../libevent源码深度剖析/libevent源码深度剖析13.html">
            
                <a href="../libevent源码深度剖析/libevent源码深度剖析13.html">
            
                    
                    libevent源码深度剖析13
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../leveldb源码分析/">
            
                <a href="../leveldb源码分析/">
            
                    
                    leveldb源码分析
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.2.1" data-path="../leveldb源码分析/leveldb源码分析1.html">
            
                <a href="../leveldb源码分析/leveldb源码分析1.html">
            
                    
                    leveldb源码分析1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.2" data-path="../leveldb源码分析/leveldb源码分析2.html">
            
                <a href="../leveldb源码分析/leveldb源码分析2.html">
            
                    
                    leveldb源码分析2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.3" data-path="../leveldb源码分析/leveldb源码分析3.html">
            
                <a href="../leveldb源码分析/leveldb源码分析3.html">
            
                    
                    leveldb源码分析3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.4" data-path="../leveldb源码分析/leveldb源码分析4.html">
            
                <a href="../leveldb源码分析/leveldb源码分析4.html">
            
                    
                    leveldb源码分析4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.5" data-path="../leveldb源码分析/leveldb源码分析5.html">
            
                <a href="../leveldb源码分析/leveldb源码分析5.html">
            
                    
                    leveldb源码分析5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.6" data-path="../leveldb源码分析/leveldb源码分析6.html">
            
                <a href="../leveldb源码分析/leveldb源码分析6.html">
            
                    
                    leveldb源码分析6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.7" data-path="../leveldb源码分析/leveldb源码分析7.html">
            
                <a href="../leveldb源码分析/leveldb源码分析7.html">
            
                    
                    leveldb源码分析7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.8" data-path="../leveldb源码分析/leveldb源码分析8.html">
            
                <a href="../leveldb源码分析/leveldb源码分析8.html">
            
                    
                    leveldb源码分析8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.9" data-path="../leveldb源码分析/leveldb源码分析9.html">
            
                <a href="../leveldb源码分析/leveldb源码分析9.html">
            
                    
                    leveldb源码分析9
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.10" data-path="../leveldb源码分析/leveldb源码分析10.html">
            
                <a href="../leveldb源码分析/leveldb源码分析10.html">
            
                    
                    leveldb源码分析10
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.11" data-path="../leveldb源码分析/leveldb源码分析11.html">
            
                <a href="../leveldb源码分析/leveldb源码分析11.html">
            
                    
                    leveldb源码分析11
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.12" data-path="../leveldb源码分析/leveldb源码分析12.html">
            
                <a href="../leveldb源码分析/leveldb源码分析12.html">
            
                    
                    leveldb源码分析12
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.13" data-path="../leveldb源码分析/leveldb源码分析13.html">
            
                <a href="../leveldb源码分析/leveldb源码分析13.html">
            
                    
                    leveldb源码分析13
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.14" data-path="../leveldb源码分析/leveldb源码分析14.html">
            
                <a href="../leveldb源码分析/leveldb源码分析14.html">
            
                    
                    leveldb源码分析14
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.15" data-path="../leveldb源码分析/leveldb源码分析15.html">
            
                <a href="../leveldb源码分析/leveldb源码分析15.html">
            
                    
                    leveldb源码分析15
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.16" data-path="../leveldb源码分析/leveldb源码分析16.html">
            
                <a href="../leveldb源码分析/leveldb源码分析16.html">
            
                    
                    leveldb源码分析16
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.17" data-path="../leveldb源码分析/leveldb源码分析17.html">
            
                <a href="../leveldb源码分析/leveldb源码分析17.html">
            
                    
                    leveldb源码分析17
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.18" data-path="../leveldb源码分析/leveldb源码分析18.html">
            
                <a href="../leveldb源码分析/leveldb源码分析18.html">
            
                    
                    leveldb源码分析18
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.19" data-path="../leveldb源码分析/leveldb源码分析19.html">
            
                <a href="../leveldb源码分析/leveldb源码分析19.html">
            
                    
                    leveldb源码分析19
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.20" data-path="../leveldb源码分析/leveldb源码分析20.html">
            
                <a href="../leveldb源码分析/leveldb源码分析20.html">
            
                    
                    leveldb源码分析20
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.21" data-path="../leveldb源码分析/leveldb源码分析21.html">
            
                <a href="../leveldb源码分析/leveldb源码分析21.html">
            
                    
                    leveldb源码分析21
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2.22" data-path="../leveldb源码分析/leveldb源码分析22.html">
            
                <a href="../leveldb源码分析/leveldb源码分析22.html">
            
                    
                    leveldb源码分析22
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="8.1" data-path="../Memcached源码分析/">
            
                <a href="../Memcached源码分析/">
            
                    
                    Memcached源码分析
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1.1" data-path="../Memcached源码分析/00服务器资源调整.html">
            
                <a href="../Memcached源码分析/00服务器资源调整.html">
            
                    
                    00 服务器资源调整
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.2" data-path="../Memcached源码分析/01初始化参数解析.html">
            
                <a href="../Memcached源码分析/01初始化参数解析.html">
            
                    
                    01 初始化参数解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.3" data-path="../Memcached源码分析/02网络监听的建立.html">
            
                <a href="../Memcached源码分析/02网络监听的建立.html">
            
                    
                    02 网络监听的建立
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.4" data-path="../Memcached源码分析/03网络连接建立.html">
            
                <a href="../Memcached源码分析/03网络连接建立.html">
            
                    
                    03 网络连接建立
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.5" data-path="../Memcached源码分析/04内存初始化.html">
            
                <a href="../Memcached源码分析/04内存初始化.html">
            
                    
                    04 内存初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.6" data-path="../Memcached源码分析/05资源初始化.html">
            
                <a href="../Memcached源码分析/05资源初始化.html">
            
                    
                    05 资源初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.7" data-path="../Memcached源码分析/06get过程.html">
            
                <a href="../Memcached源码分析/06get过程.html">
            
                    
                    06 get过程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.8" data-path="../Memcached源码分析/07cas属性.html">
            
                <a href="../Memcached源码分析/07cas属性.html">
            
                    
                    07 cas属性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.9" data-path="../Memcached源码分析/08内存池.html">
            
                <a href="../Memcached源码分析/08内存池.html">
            
                    
                    08 内存池
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.10" data-path="../Memcached源码分析/09连接队列.html">
            
                <a href="../Memcached源码分析/09连接队列.html">
            
                    
                    09 连接队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.11" data-path="../Memcached源码分析/10Hash表操作.html">
            
                <a href="../Memcached源码分析/10Hash表操作.html">
            
                    
                    10 Hash表操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.12" data-path="../Memcached源码分析/12set操作.html">
            
                <a href="../Memcached源码分析/12set操作.html">
            
                    
                    12 set操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.13" data-path="../Memcached源码分析/13do_item_alloc操作.html">
            
                <a href="../Memcached源码分析/13do_item_alloc操作.html">
            
                    
                    13 do_item_alloc操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.14" data-path="../Memcached源码分析/14item结构.html">
            
                <a href="../Memcached源码分析/14item结构.html">
            
                    
                    14 item结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.15" data-path="../Memcached源码分析/15Hash表扩容.html">
            
                <a href="../Memcached源码分析/15Hash表扩容.html">
            
                    
                    15 Hash表扩容
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.16" data-path="../Memcached源码分析/16线程交互.html">
            
                <a href="../Memcached源码分析/16线程交互.html">
            
                    
                    16 线程交互
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="8.1.17" data-path="../Memcached源码分析/17状态机.html">
            
                <a href="../Memcached源码分析/17状态机.html">
            
                    
                    17 状态机
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="9.1" data-path="../游戏开发专题/">
            
                <a href="../游戏开发专题/">
            
                    
                    游戏开发专题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="9.1.1" data-path="../游戏开发专题/1游戏服务器开发的基本体系与服务器端开发的一些建议.html">
            
                <a href="../游戏开发专题/1游戏服务器开发的基本体系与服务器端开发的一些建议.html">
            
                    
                    1 游戏服务器开发的基本体系与服务器端开发的一些建议
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.2" data-path="../游戏开发专题/2网络游戏服务器开发框架设计介绍.html">
            
                <a href="../游戏开发专题/2网络游戏服务器开发框架设计介绍.html">
            
                    
                    2 网络游戏服务器开发框架设计介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.3" data-path="../游戏开发专题/3游戏后端开发需要掌握的知识.html">
            
                <a href="../游戏开发专题/3游戏后端开发需要掌握的知识.html">
            
                    
                    3 游戏后端开发需要掌握的知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.4" data-path="../游戏开发专题/4关于游戏服务端架构的整理.html">
            
                <a href="../游戏开发专题/4关于游戏服务端架构的整理.html">
            
                    
                    4 关于游戏服务端架构的整理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.5" data-path="../游戏开发专题/5各类游戏对应的服务端架构.html">
            
                <a href="../游戏开发专题/5各类游戏对应的服务端架构.html">
            
                    
                    5 各类游戏对应的服务端架构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.6" data-path="../游戏开发专题/6从腾讯QQgame高性能服务器集群架构看“分而治之”与“自治”等分布式架构设计原则.html">
            
                <a href="../游戏开发专题/6从腾讯QQgame高性能服务器集群架构看“分而治之”与“自治”等分布式架构设计原则.html">
            
                    
                    6 从腾讯QQgame高性能服务器集群架构看“分而治之”与“自治”等分布式架构设计原则
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.7" data-path="../游戏开发专题/7QQ游戏百万人同时在线服务器架构实现.html">
            
                <a href="../游戏开发专题/7QQ游戏百万人同时在线服务器架构实现.html">
            
                    
                    7 QQ游戏百万人同时在线服务器架构实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.8" data-path="../游戏开发专题/8大型多人在线游戏服务器架构设计.html">
            
                <a href="../游戏开发专题/8大型多人在线游戏服务器架构设计.html">
            
                    
                    8 大型多人在线游戏服务器架构设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.9" data-path="../游戏开发专题/9百万用户级游戏服务器架构设计.html">
            
                <a href="../游戏开发专题/9百万用户级游戏服务器架构设计.html">
            
                    
                    9 百万用户级游戏服务器架构设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.10" data-path="../游戏开发专题/10十万在线的WebGame的数据库设计思路.html">
            
                <a href="../游戏开发专题/10十万在线的WebGame的数据库设计思路.html">
            
                    
                    10 十万在线的WebGame的数据库设计思路
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.11" data-path="../游戏开发专题/11一种高性能网络游戏服务器架构设计.html">
            
                <a href="../游戏开发专题/11一种高性能网络游戏服务器架构设计.html">
            
                    
                    11 一种高性能网络游戏服务器架构设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.12" data-path="../游戏开发专题/12经典游戏服务器端架构概述.html">
            
                <a href="../游戏开发专题/12经典游戏服务器端架构概述.html">
            
                    
                    12 经典游戏服务器端架构概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.1.13" data-path="../游戏开发专题/13游戏跨服架构进化之路.html">
            
                <a href="../游戏开发专题/13游戏跨服架构进化之路.html">
            
                    
                    13 游戏跨服架构进化之路
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">Part IV</li>
        
        
    
        <li class="chapter " data-level="10.1" data-path="../程序员面试题精讲/">
            
                <a href="../程序员面试题精讲/">
            
                    
                    程序员面试题精讲
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.1.1" data-path="../程序员面试题精讲/腾讯后台开发实习生技能要求.html">
            
                <a href="../程序员面试题精讲/腾讯后台开发实习生技能要求.html">
            
                    
                    腾讯后台开发实习生技能要求
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="10.1.2" data-path="../程序员面试题精讲/聊聊如何拿大厂的offer.html">
            
                <a href="../程序员面试题精讲/聊聊如何拿大厂的offer.html">
            
                    
                    聊聊如何拿大厂的 offer
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="10.1.3" data-path="../程序员面试题精讲/网络通信题目集锦.html">
            
                <a href="../程序员面试题精讲/网络通信题目集锦.html">
            
                    
                    网络通信题目集锦
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="10.1.4" data-path="../程序员面试题精讲/我面试后端开发经理的经历.html">
            
                <a href="../程序员面试题精讲/我面试后端开发经理的经历.html">
            
                    
                    我面试后端开发经理的经历
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="10.1.5" data-path="../程序员面试题精讲/LinuxCC++后端开发面试问哪些问题.html">
            
                <a href="../程序员面试题精讲/LinuxCC++后端开发面试问哪些问题.html">
            
                    
                    Linux C/C++后端开发面试问哪些问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10.2" data-path="../职业规划/">
            
                <a href="../职业规划/">
            
                    
                    职业规划
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.2.1" data-path="../职业规划/给工作4年迷茫的程序员们的一点建议.html">
            
                <a href="../职业规划/给工作4年迷茫的程序员们的一点建议.html">
            
                    
                    给工作 4 年迷茫的程序员们的一点建议
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="10.2.2" data-path="../职业规划/聊聊技术人员的常见的职业问题.html">
            
                <a href="../职业规划/聊聊技术人员的常见的职业问题.html">
            
                    
                    聊聊技术人员的常见的职业问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="10.2.3" data-path="../职业规划/写给那些傻傻想做服务器开发的朋友.html">
            
                <a href="../职业规划/写给那些傻傻想做服务器开发的朋友.html">
            
                    
                    写给那些傻傻想做服务器开发的朋友
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10.3" data-path="../自我提升与开源代码/">
            
                <a href="../自我提升与开源代码/">
            
                    
                    自我提升与开源代码
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.3.1" data-path="../自我提升与开源代码/2020年好好读一读开源代码吧.html">
            
                <a href="../自我提升与开源代码/2020年好好读一读开源代码吧.html">
            
                    
                    2020 年好好读一读开源代码吧
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10.4" data-path="../后端开发相关的书籍/">
            
                <a href="../后端开发相关的书籍/">
            
                    
                    后端开发相关的书籍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.4.1" data-path="../后端开发相关的书籍/后台开发应该读的书.html">
            
                <a href="../后端开发相关的书籍/后台开发应该读的书.html">
            
                    
                    后台开发应该读的书
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10.5" data-path="../程序员的简历/">
            
                <a href="../程序员的简历/">
            
                    
                    程序员的简历
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.5.1" data-path="../程序员的简历/程序员如何写简历.html">
            
                <a href="../程序员的简历/程序员如何写简历.html">
            
                    
                    程序员如何写简历
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10.6" data-path="../程序员的薪资与年终奖那些事儿/">
            
                <a href="../程序员的薪资与年终奖那些事儿/">
            
                    
                    程序员的薪资与年终奖那些事儿
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.6.1" data-path="../程序员的薪资与年终奖那些事儿/技术面试与HR谈薪资技巧.html">
            
                <a href="../程序员的薪资与年终奖那些事儿/技术面试与HR谈薪资技巧.html">
            
                    
                    技术面试与HR谈薪资技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="10.6.2" data-path="../程序员的薪资与年终奖那些事儿/聊一聊程序员如何增加收入.html">
            
                <a href="../程序员的薪资与年终奖那些事儿/聊一聊程序员如何增加收入.html">
            
                    
                    聊一聊程序员如何增加收入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="10.6.3" data-path="../程序员的薪资与年终奖那些事儿/谈一谈年终奖.html">
            
                <a href="../程序员的薪资与年终奖那些事儿/谈一谈年终奖.html">
            
                    
                    谈一谈年终奖
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10.7" data-path="../程序员的烦心事/">
            
                <a href="../程序员的烦心事/">
            
                    
                    程序员的烦心事
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.7.1" data-path="../程序员的烦心事/拒绝了一家公司的offer后，他们的副总和hr总监同时打电话来询问拒绝原因并极力要求加入，我该不该去？.html">
            
                <a href="../程序员的烦心事/拒绝了一家公司的offer后，他们的副总和hr总监同时打电话来询问拒绝原因并极力要求加入，我该不该去？.html">
            
                    
                    拒绝了一家公司的offer后，他们的副总和hr总监同时打电话来询问拒绝原因并极力要求加入，我该不该去？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="10.7.2" data-path="../程序员的烦心事/我是一名程序员，结婚时女友要求我用两年的工资作为彩礼，我该不该答应？.html">
            
                <a href="../程序员的烦心事/我是一名程序员，结婚时女友要求我用两年的工资作为彩礼，我该不该答应？.html">
            
                    
                    我是一名程序员，结婚时女友要求我用两年的工资作为彩礼，我该不该答应？
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10.8" data-path="../作者的故事/">
            
                <a href="../作者的故事/">
            
                    
                    作者的故事
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.8.1" data-path="../作者的故事/我的2019.html">
            
                <a href="../作者的故事/我的2019.html">
            
                    
                    我的 2019
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="10.8.2" data-path="../作者的故事/我是如何年薪五十万的.html">
            
                <a href="../作者的故事/我是如何年薪五十万的.html">
            
                    
                    我是如何年薪五十万的
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


		</nav>
		
		
	</div>

	<!-- Content nav -->
	<div class="book-anchor">
		<div class="book-anchor-title">在这篇文章中:</div>
		<div class="book-anchor-body">

		</div>
	</div>

	<div class="book-body">
		
		<div class="body-inner">
			
			

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >08 服务器端file_server源码分析</a>
    </h1>
</div>




			<div class="page-wrapper" tabindex="-1" role="main">
				<div class="page-inner">
					
<div id="book-search-results">
    <div class="search-noresults">
    
					<section class="normal markdown-section">
						
						<div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#08-&#x670D;&#x52A1;&#x5668;&#x7AEF;fileserver&#x6E90;&#x7801;&#x5206;&#x6790;"><b></b>08 &#x670D;&#x52A1;&#x5668;&#x7AEF;file_server&#x6E90;&#x7801;&#x5206;&#x6790;</a></li></ul></div><h1 id="08-&#x670D;&#x52A1;&#x5668;&#x7AEF;fileserver&#x6E90;&#x7801;&#x5206;&#x6790;"><a name="08-&#x670D;&#x52A1;&#x5668;&#x7AEF;fileserver&#x6E90;&#x7801;&#x5206;&#x6790;" class="anchor-navigation-ex-anchor" href="#08-&#x670D;&#x52A1;&#x5668;&#x7AEF;fileserver&#x6E90;&#x7801;&#x5206;&#x6790;"><i class="fa fa-link" aria-hidden="true"></i></a>08 &#x670D;&#x52A1;&#x5668;&#x7AEF;file_server&#x6E90;&#x7801;&#x5206;&#x6790;</h1>
<p>&#x8FD9;&#x7BC7;&#x6587;&#x7AE0;&#x6211;&#x4EEC;&#x6765;&#x4ECB;&#x7ECD;file_server&#x670D;&#x52A1;&#x7684;&#x529F;&#x80FD;&#x548C;&#x6E90;&#x7801;&#x5B9E;&#x73B0;&#x3002;TeamTalk&#x652F;&#x6301;&#x79BB;&#x7EBF;&#x5728;&#x7EBF;&#x6587;&#x4EF6;&#x548C;&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#x4E24;&#x79CD;&#x4F20;&#x9001;&#x6587;&#x4EF6;&#x7684;&#x65B9;&#x5F0F;&#x3002;&#x5355;&#x7EAF;&#x5730;&#x7814;&#x7A76;file_server&#x7684;&#x7A0B;&#x5E8F;&#x7ED3;&#x6784;&#x6CA1;&#x591A;&#x5927;&#x610F;&#x4E49;&#xFF0C;&#x56E0;&#x4E3A;&#x5176;&#x7A0B;&#x5E8F;&#x7ED3;&#x6784;&#x548C;&#x5176;&#x4ED6;&#x51E0;&#x4E2A;&#x670D;&#x52A1;&#x7ED3;&#x6784;&#x57FA;&#x672C;&#x4E0A;&#x4E00;&#x6A21;&#x4E00;&#x6837;&#xFF0C;&#x524D;&#x9762;&#x51E0;&#x7BC7;&#x6587;&#x7AE0;&#x5DF2;&#x7ECF;&#x4ECB;&#x7ECD;&#x8FC7;&#x4E86;&#x3002; &#x6211;&#x4EEC;&#x7814;&#x7A76;teamtalk&#x7684;file_server&#x662F;&#x4E3A;&#x4E86;&#x5B66;&#x4E60;&#x548C;&#x501F;&#x9274;teamtalk&#x7684;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x529F;&#x80FD;&#x5B9E;&#x73B0;&#x601D;&#x8DEF;&#xFF0C;&#x4EE5;&#x5185;&#x5316;&#x4E3A;&#x81EA;&#x5DF1;&#x7684;&#x77E5;&#x8BC6;&#xFF0C;&#x5E76;&#x52A0;&#x4EE5;&#x5E94;&#x7528;&#x3002;</p>
<p>&#x6240;&#x4EE5;&#x8FD9;&#x7BC7;&#x6587;&#x7AE0;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;pc&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x529F;&#x80FD;&#x3001;msg_server&#x8F6C;&#x53D1;&#x6D88;&#x606F;&#x3001;file_server&#x5904;&#x7406;&#x6587;&#x4EF6;&#x6570;&#x636E;&#x4E09;&#x4E2A;&#x65B9;&#x9762;&#x7ED3;&#x5408;&#x8D77;&#x6765;&#x4E00;&#x8D77;&#x4ECB;&#x7ECD;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x5F00;&#x59CB;&#x5566;&#x3002;</p>
<p><img src="../imgs/tt13.jpg" alt=""><img src="" alt="&#x70B9;&#x51FB;&#x5E76;&#x62D6;&#x62FD;&#x4EE5;&#x79FB;&#x52A8;"></p>
<p>&#x4E00;&#x3001;&#x8FDE;&#x63A5;&#x72B6;&#x51B5;&#x4ECB;&#x7ECD;</p>
<p>fileserver&#x5F00;&#x59CB;&#x5E76;&#x4E0D;&#x662F;&#x548C;&#x5BA2;&#x6237;&#x7AEF;&#x8FDE;&#x63A5;&#x7684;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x662F;&#x6309;&#x9700;&#x8FDE;&#x63A5;file_server&#x7684;&#x3002;&#x4F46;&#x662F;file_server&#x4E0E;msg_server&#x5374;&#x662F;&#x957F;&#x8FDE;&#x63A5;&#x3002;&#x5148;&#x542F;&#x52A8;file_server&#xFF0C;&#x518D;&#x542F;&#x52A8;msg_server&#x3002;msg_server&#x521D;&#x59CB;&#x5316;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F1A;&#x53BB;&#x5C1D;&#x8BD5;&#x8FDE;&#x63A5;file_server&#x7684;8601&#x7AEF;&#x53E3;&#x3002;&#x8FDE;&#x63A5;&#x6210;&#x529F;&#x4EE5;&#x540E;&#xFF0C;&#x4F1A;&#x7ED9;file_server&#x53D1;&#x9001;&#x4E00;&#x4E2A;&#x53D1;&#x5305;&#x8BE2;&#x95EE;file_server&#x4FA6;&#x542C;&#x5BA2;&#x6237;&#x7AEF;&#x8FDE;&#x63A5;&#x7684;ip&#x548C;&#x7AEF;&#x53E3;&#x53F7;&#x4FE1;&#x606F;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">CFileServConn</span><span class="token operator">::</span><span class="token function">OnConfirm</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;connect to file server success &quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    m_bOpen <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
    m_connect_time <span class="token operator">=</span> <span class="token function">get_tick_count</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    g_file_server_list<span class="token punctuation">[</span>m_serv_idx<span class="token punctuation">]</span><span class="token punctuation">.</span>reconnect_cnt <span class="token operator">=</span> MIN_RECONNECT_CNT <span class="token operator">/</span> <span class="token number">2</span><span class="token punctuation">;</span>

    <span class="token comment">//&#x8FDE;&#x4E0A;file_server&#x4EE5;&#x540E;&#xFF0C;&#x7ED9;file_server&#x53D1;&#x9001;&#x83B7;&#x53D6;ip&#x5730;&#x5740;&#x7684;&#x6570;&#x636E;&#x5305;</span>
    IM<span class="token operator">::</span>Server<span class="token operator">::</span>IMFileServerIPReq msg<span class="token punctuation">;</span>
    CImPdu pdu<span class="token punctuation">;</span>
    pdu<span class="token punctuation">.</span><span class="token function">SetPBMsg</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>msg<span class="token punctuation">)</span><span class="token punctuation">;</span>
    pdu<span class="token punctuation">.</span><span class="token function">SetServiceId</span><span class="token punctuation">(</span>SID_OTHER<span class="token punctuation">)</span><span class="token punctuation">;</span>
    pdu<span class="token punctuation">.</span><span class="token function">SetCommandId</span><span class="token punctuation">(</span>CID_OTHER_FILE_SERVER_IP_REQ<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">SendPdu</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>pdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>file_server&#x6536;&#x5230;&#x8BE5;&#x6570;&#x636E;&#x5305;&#x540E;&#xFF0C;&#x5C06;&#x81EA;&#x5DF1;&#x7684;&#x4FA6;&#x542C;&#x5BA2;&#x6237;&#x7AEF;&#x8FDE;&#x63A5;&#x7684;ip&#x5730;&#x5740;&#x548C;&#x7AEF;&#x53E3;&#x53F7;&#x53D1;&#x5305;&#x544A;&#x8BC9;msg_server&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileMsgServerConn</span><span class="token operator">::</span><span class="token function">_HandleGetServerAddressReq</span><span class="token punctuation">(</span>CImPdu<span class="token operator">*</span> pPdu<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    IM<span class="token operator">::</span>Server<span class="token operator">::</span>IMFileServerIPRsp msg<span class="token punctuation">;</span>

    <span class="token keyword">const</span> std<span class="token operator">::</span>list<span class="token operator">&lt;</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr<span class="token operator">&gt;</span><span class="token operator">&amp;</span> addrs <span class="token operator">=</span> <span class="token class-name">ConfigUtil</span><span class="token operator">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">GetAddressList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span> <span class="token punctuation">(</span>std<span class="token operator">::</span>list<span class="token operator">&lt;</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr<span class="token operator">&gt;</span><span class="token operator">::</span>const_iterator it<span class="token operator">=</span>addrs<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> it<span class="token operator">!=</span>addrs<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token operator">++</span>it<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr<span class="token operator">*</span> addr <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">add_ip_addr_list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token operator">*</span>addr <span class="token operator">=</span> <span class="token operator">*</span>it<span class="token punctuation">;</span>
        <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Upload file_client_conn addr info, ip=%s, port=%d&quot;</span><span class="token punctuation">,</span> addr<span class="token operator">-&gt;</span><span class="token function">ip</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> addr<span class="token operator">-&gt;</span><span class="token function">port</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token function">SendMessageLite</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> SID_OTHER<span class="token punctuation">,</span> CID_OTHER_FILE_SERVER_IP_RSP<span class="token punctuation">,</span> pPdu<span class="token operator">-&gt;</span><span class="token function">GetSeqNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>msg<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5F97;&#x5230;&#x7684;&#x4FE1;&#x606F;&#x662F;file_server&#x4FA6;&#x542C;&#x7684;ip&#x5730;&#x5740;&#x548C;&#x7AEF;&#x53E3;&#x53F7;&#xFF0C;&#x9ED8;&#x8BA4;&#x914D;&#x7F6E;&#x7684;&#x7AEF;&#x53E3;&#x53F7;&#x662F;8600&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;file_server&#x7684;8600&#x7528;&#x4E8E;&#x5BA2;&#x6237;&#x7AEF;&#x8FDE;&#x63A5;&#xFF0C;8601&#x7AEF;&#x53E3;&#x7528;&#x4E8E;msg_server&#x8FDE;&#x63A5;&#x3002;&#x8FD9;&#x6837;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x9700;&#x8981;&#x4F20;&#x8F93;&#x6587;&#x4EF6;&#xFF08;&#x6CE8;&#x610F;&#xFF1A;&#x4E0D;&#x662F;&#x804A;&#x5929;&#x56FE;&#x7247;&#xFF0C;&#x804A;&#x5929;&#x56FE;&#x7247;&#x4F7F;&#x7528;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x670D;&#x52A1;msfs&#x8FDB;&#x884C;&#x4F20;&#x8F93;&#xFF09;&#xFF0C;&#x4F1A;&#x5148;&#x544A;&#x8BC9;msg_server&#x5B83;&#x9700;&#x8981;&#x8FDB;&#x884C;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#xFF0C;msg_server&#x6536;&#x5230;&#x6D88;&#x606F;&#x540E;&#x544A;&#x8BC9;&#x5BA2;&#x6237;&#x7AEF;&#xFF0C;&#x4F60;&#x8FDE;file_server&#x6765;&#x4F20;&#x8F93;&#x6587;&#x4EF6;&#x5427;&#xFF0C;&#x5E76;&#x628A;file_server&#x7684;&#x5730;&#x5740;&#x548C;&#x7AEF;&#x53E3;&#x53F7;&#x544A;&#x8BC9;&#x5BA2;&#x6237;&#x7AEF;&#x3002;&#x5BA2;&#x6237;&#x7AEF;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x8FDE;&#x63A5;file_server&#x8FDB;&#x884C;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x3002;&#x6211;&#x4EEC;&#x6765;&#x5177;&#x4F53;&#x770B;&#x4E00;&#x770B;&#x8FD9;&#x4E2A;&#x6D41;&#x7A0B;&#x7684;&#x7EC6;&#x8282;&#x4FE1;&#x606F;&#xFF1A;</p>
<ol>
<li>&#x5BA2;&#x6237;&#x7AEF;&#x53D1;&#x5305;&#x7ED9;msg_server&#x8BF4;&#x8981;&#x8FDB;&#x884C;&#x6587;&#x4EF6;&#x53D1;&#x9001;</li>
</ol>
<p><img src="../imgs/tt14.jpg" alt=""></p>
<p>&#x7136;&#x540E;&#x9009;&#x62E9;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#xFF1A;</p>
<p><img src="../imgs/tt15.jpg" alt=""></p>
<p>pc&#x5BA2;&#x6237;&#x7AEF;&#x53D1;&#x9001;&#x6587;&#x4EF6;&#x903B;&#x8F91;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token comment">//pc&#x5BA2;&#x6237;&#x7AEF;&#x4EE3;&#x7801;(Modules&#x5DE5;&#x7A0B;SessionLayout.cpp)</span>
<span class="token keyword">void</span> <span class="token class-name">SessionLayout</span><span class="token operator">::</span><span class="token function">Notify</span><span class="token punctuation">(</span>TNotifyUI<span class="token operator">&amp;</span> msg<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>msg<span class="token punctuation">.</span>pSender <span class="token operator">==</span> m_pBtnsendfile<span class="token punctuation">)</span> <span class="token comment">//&#x6587;&#x4EF6;&#x4F20;&#x8F93;</span>
    <span class="token punctuation">{</span>
        module<span class="token operator">::</span>UserInfoEntity userInfo<span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>module<span class="token operator">::</span><span class="token function">getUserListModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">getUserInfoBySId</span><span class="token punctuation">(</span>m_sId<span class="token punctuation">,</span> userInfo<span class="token punctuation">)</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;SendFile can&apos;t find the sid&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">return</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        CFileDialog    <span class="token function">fileDlg</span><span class="token punctuation">(</span>TRUE<span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> OFN_HIDEREADONLY <span class="token operator">|</span> OFN_FILEMUSTEXIST
            <span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;&#x6587;&#x4EF6;|*.*||&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">AfxGetMainWnd</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        fileDlg<span class="token punctuation">.</span>m_ofn<span class="token punctuation">.</span>Flags <span class="token operator">|=</span> OFN_NOCHANGEDIR<span class="token punctuation">;</span>
        fileDlg<span class="token punctuation">.</span><span class="token function">DoModal</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        CString sPathName<span class="token punctuation">;</span>
        POSITION nPos <span class="token operator">=</span> fileDlg<span class="token punctuation">.</span><span class="token function">GetStartPosition</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>nPos <span class="token operator">!=</span> <span class="token constant">NULL</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            sPathName <span class="token operator">=</span> fileDlg<span class="token punctuation">.</span><span class="token function">GetNextPathName</span><span class="token punctuation">(</span>nPos<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>sPathName<span class="token punctuation">.</span><span class="token function">IsEmpty</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token keyword">return</span><span class="token punctuation">;</span>

        module<span class="token operator">::</span><span class="token function">getFileTransferModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">sendFile</span><span class="token punctuation">(</span>sPathName<span class="token punctuation">,</span> m_sId<span class="token punctuation">,</span> userInfo<span class="token punctuation">.</span><span class="token function">isOnlne</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>sPathName&#x662F;&#x6587;&#x4EF6;&#x7684;&#x5168;&#x9970;&#x8DEF;&#x5F84;&#xFF1B;m_sId&#x662F;&#x6536;&#x53D6;&#x6587;&#x4EF6;&#x7684;&#x7528;&#x6237;id&#xFF0C;userInfo.isOnlne()&#x5224;&#x65AD;m_sId&#x4EE3;&#x8868;&#x7684;&#x7528;&#x6237;&#x662F;&#x5426;&#x5728;&#x7EBF;&#xFF0C;&#x4EE5;&#x6B64;&#x6765;&#x51B3;&#x5B9A;&#x8FD9;&#x6B21;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x662F;&#x5728;&#x7EBF;&#x6587;&#x4EF6;&#x8FD8;&#x662F;&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#x6A21;&#x5F0F;&#x3002;</p>
<pre class="language-"><code class="lang-cpp">BOOL <span class="token class-name">FileTransferModule_Impl</span><span class="token operator">::</span><span class="token function">sendFile</span><span class="token punctuation">(</span>IN <span class="token keyword">const</span> CString<span class="token operator">&amp;</span> sFilePath<span class="token punctuation">,</span> IN <span class="token keyword">const</span> std<span class="token operator">::</span>string<span class="token operator">&amp;</span> sSendToSID<span class="token punctuation">,</span>IN BOOL bOnlineMode<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">checkIfIsSending</span><span class="token punctuation">(</span>sFilePath<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token keyword">return</span> FALSE<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    TransferFileEntity fileEntity<span class="token punctuation">;</span>

    <span class="token comment">//&#x83B7;&#x53D6;&#x6587;&#x4EF6;&#x5927;&#x5C0F;</span>
    <span class="token keyword">struct</span> <span class="token class-name">__stat64</span> buffer<span class="token punctuation">;</span>
    <span class="token function">_wstat64</span><span class="token punctuation">(</span>sFilePath<span class="token punctuation">,</span> <span class="token operator">&amp;</span>buffer<span class="token punctuation">)</span><span class="token punctuation">;</span>
    fileEntity<span class="token punctuation">.</span>nFileSize <span class="token operator">=</span> <span class="token punctuation">(</span>UInt32<span class="token punctuation">)</span>buffer<span class="token punctuation">.</span>st_size<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token number">0</span> <span class="token operator">!=</span> fileEntity<span class="token punctuation">.</span>nFileSize<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        CString strFileName <span class="token operator">=</span> sFilePath<span class="token punctuation">;</span>
        strFileName<span class="token punctuation">.</span><span class="token function">Replace</span><span class="token punctuation">(</span><span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;\\&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;/&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//mac&#x4E0A;&#x5BF9;&#x4E8E;&#x8DEF;&#x5F84;&#x5B57;&#x7B26;&#x201C;\&#x201D;&#x9700;&#x8981;&#x505A;&#x7279;&#x6B8A;&#x5904;&#x7406;&#xFF0C;windows&#x4E0A;&#x5219;&#x53EF;&#x4EE5;&#x8BC6;&#x522B;</span>
        fileEntity<span class="token punctuation">.</span>sFileName <span class="token operator">=</span> util<span class="token operator">::</span><span class="token function">cStringToString</span><span class="token punctuation">(</span>strFileName<span class="token punctuation">)</span><span class="token punctuation">;</span>
        fileEntity<span class="token punctuation">.</span>sFromID <span class="token operator">=</span> module<span class="token operator">::</span><span class="token function">getSysConfigModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">userID</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        fileEntity<span class="token punctuation">.</span>sToID <span class="token operator">=</span> sSendToSID<span class="token punctuation">;</span>
        <span class="token keyword">uint32_t</span> transMode <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
        transMode <span class="token operator">=</span> bOnlineMode <span class="token operator">?</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token operator">::</span>FILE_TYPE_ONLINE <span class="token operator">:</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token operator">::</span>FILE_TYPE_OFFLINE<span class="token punctuation">;</span>

        <span class="token function">LOG__</span><span class="token punctuation">(</span>DEBG<span class="token punctuation">,</span><span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;FileTransferSevice_Impl::sendFile sTaskID = %s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        imcore<span class="token operator">::</span><span class="token function">IMLibCoreStartOperationWithLambda</span><span class="token punctuation">(</span>
            <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileReq imFileReq<span class="token punctuation">;</span>
            <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;imFileReq,name=%s,size=%d,toId=%s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sFileName<span class="token punctuation">)</span>
                <span class="token punctuation">,</span>fileEntity<span class="token punctuation">.</span>nFileSize<span class="token punctuation">,</span>util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sToID<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            imFileReq<span class="token punctuation">.</span><span class="token function">set_from_user_id</span><span class="token punctuation">(</span>util<span class="token operator">::</span><span class="token function">stringToInt32</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sFromID<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            imFileReq<span class="token punctuation">.</span><span class="token function">set_to_user_id</span><span class="token punctuation">(</span>util<span class="token operator">::</span><span class="token function">stringToInt32</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sToID<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            imFileReq<span class="token punctuation">.</span><span class="token function">set_file_name</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sFileName<span class="token punctuation">)</span><span class="token punctuation">;</span>
            imFileReq<span class="token punctuation">.</span><span class="token function">set_file_size</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>nFileSize<span class="token punctuation">)</span><span class="token punctuation">;</span>
            imFileReq<span class="token punctuation">.</span><span class="token function">set_trans_mode</span><span class="token punctuation">(</span><span class="token keyword">static_cast</span><span class="token operator">&lt;</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token operator">&gt;</span><span class="token punctuation">(</span>transMode<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

            module<span class="token operator">::</span><span class="token function">getTcpClientModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">sendPacket</span><span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ServiceID<span class="token operator">::</span>SID_FILE
                <span class="token punctuation">,</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FileCmdID<span class="token operator">::</span>CID_FILE_REQUEST
                <span class="token punctuation">,</span> <span class="token operator">&amp;</span>imFileReq<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">return</span> TRUE<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;fileEntity FileSize error,size = %d&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> fileEntity<span class="token punctuation">.</span>nFileSize<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> FALSE<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x4E2D;&#x7EC4;&#x88C5;&#x7684;&#x5305;&#x4FE1;&#x606F;&#x4E2D;&#x542B;&#x6709;&#x8981;&#x4F20;&#x8F93;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x3001;&#x6587;&#x4EF6;&#x5927;&#x5C0F;&#x3001;&#x53D1;&#x9001;&#x4EBA;id&#x3001;&#x63A5;&#x6536;&#x65B9;id&#x3001;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x6A21;&#x5F0F;&#xFF08;&#x5728;&#x7EBF;&#x8FD8;&#x662F;&#x79BB;&#x7EBF;&#xFF09;&#xFF0C;&#x5305;&#x7684;&#x547D;&#x4EE4;&#x53F7;&#x662F;IM::BaseDefine::FileCmdID::CID_FILE_REQUEST&#x3002;&#x8FD9;&#x4E2A;&#x5305;&#x53D1;&#x7ED9;msg_server&#x4EE5;&#x540E;&#xFF0C;msg_server&#x5E94;&#x7B54;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">CMsgConn</span><span class="token operator">::</span><span class="token function">HandlePdu</span><span class="token punctuation">(</span>CImPdu<span class="token operator">*</span> pPdu<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
<span class="token keyword">case</span> CID_FILE_REQUEST<span class="token operator">:</span>
            s_file_handler<span class="token operator">-&gt;</span><span class="token function">HandleClientFileRequest</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> pPdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">CFileHandler</span><span class="token operator">::</span><span class="token function">HandleClientFileRequest</span><span class="token punctuation">(</span>CMsgConn<span class="token operator">*</span> pMsgConn<span class="token punctuation">,</span> CImPdu<span class="token operator">*</span> pPdu<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileReq msg<span class="token punctuation">;</span>
    <span class="token function">CHECK_PB_PARSE_MSG</span><span class="token punctuation">(</span>msg<span class="token punctuation">.</span><span class="token function">ParseFromArray</span><span class="token punctuation">(</span>pPdu<span class="token operator">-&gt;</span><span class="token function">GetBodyData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> pPdu<span class="token operator">-&gt;</span><span class="token function">GetBodyLength</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">uint32_t</span> from_id <span class="token operator">=</span> pMsgConn<span class="token operator">-&gt;</span><span class="token function">GetUserId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> to_id <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">to_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    string file_name <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">file_name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> file_size <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">file_size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> trans_mode <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;HandleClientFileRequest, %u-&gt;%u, fileName: %s, trans_mode: %u.&quot;</span><span class="token punctuation">,</span> from_id<span class="token punctuation">,</span> to_id<span class="token punctuation">,</span> file_name<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> trans_mode<span class="token punctuation">)</span><span class="token punctuation">;</span>

    CDbAttachData <span class="token function">attach</span><span class="token punctuation">(</span>ATTACH_TYPE_HANDLE<span class="token punctuation">,</span> pMsgConn<span class="token operator">-&gt;</span><span class="token function">GetHandle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    CFileServConn<span class="token operator">*</span> pFileConn <span class="token operator">=</span> <span class="token function">get_random_file_serv_conn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>pFileConn<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        IM<span class="token operator">::</span>Server<span class="token operator">::</span>IMFileTransferReq msg2<span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_from_user_id</span><span class="token punctuation">(</span>from_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_to_user_id</span><span class="token punctuation">(</span>to_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_file_name</span><span class="token punctuation">(</span>file_name<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_file_size</span><span class="token punctuation">(</span>file_size<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token punctuation">)</span>trans_mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_attach_data</span><span class="token punctuation">(</span>attach<span class="token punctuation">.</span><span class="token function">GetBuffer</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> attach<span class="token punctuation">.</span><span class="token function">GetLength</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        CImPdu pdu<span class="token punctuation">;</span>
        pdu<span class="token punctuation">.</span><span class="token function">SetPBMsg</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>msg2<span class="token punctuation">)</span><span class="token punctuation">;</span>
        pdu<span class="token punctuation">.</span><span class="token function">SetServiceId</span><span class="token punctuation">(</span>SID_OTHER<span class="token punctuation">)</span><span class="token punctuation">;</span>
        pdu<span class="token punctuation">.</span><span class="token function">SetCommandId</span><span class="token punctuation">(</span>CID_OTHER_FILE_TRANSFER_REQ<span class="token punctuation">)</span><span class="token punctuation">;</span>
        pdu<span class="token punctuation">.</span><span class="token function">SetSeqNum</span><span class="token punctuation">(</span>pPdu<span class="token operator">-&gt;</span><span class="token function">GetSeqNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FILE_TYPE_OFFLINE <span class="token operator">==</span> trans_mode<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            pFileConn<span class="token operator">-&gt;</span><span class="token function">SendPdu</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>pdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">else</span> <span class="token comment">//IM::BaseDefine::FILE_TYPE_ONLINE</span>
        <span class="token punctuation">{</span>
            CImUser<span class="token operator">*</span> pUser <span class="token operator">=</span> <span class="token class-name">CImUserManager</span><span class="token operator">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">GetImUserById</span><span class="token punctuation">(</span>to_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>pUser <span class="token operator">&amp;&amp;</span> pUser<span class="token operator">-&gt;</span><span class="token function">GetPCLoginStatus</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token comment">//&#x5DF2;&#x6709;&#x5BF9;&#x5E94;&#x7684;&#x8D26;&#x53F7;pc&#x767B;&#x5F55;&#x72B6;&#x6001;</span>
            <span class="token punctuation">{</span>
                pFileConn<span class="token operator">-&gt;</span><span class="token function">SendPdu</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>pdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">else</span><span class="token comment">//&#x65E0;&#x5BF9;&#x5E94;&#x7528;&#x6237;&#x7684;pc&#x767B;&#x5F55;&#x72B6;&#x6001;,&#x5411;route_server&#x67E5;&#x8BE2;&#x72B6;&#x6001;</span>
            <span class="token punctuation">{</span>
                <span class="token comment">//no pc_client in this msg_server, check it from route_server</span>
                CPduAttachData <span class="token function">attach_data</span><span class="token punctuation">(</span>ATTACH_TYPE_HANDLE_AND_PDU_FOR_FILE<span class="token punctuation">,</span> pMsgConn<span class="token operator">-&gt;</span><span class="token function">GetHandle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> pdu<span class="token punctuation">.</span><span class="token function">GetBodyLength</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> pdu<span class="token punctuation">.</span><span class="token function">GetBodyData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                IM<span class="token operator">::</span>Buddy<span class="token operator">::</span>IMUsersStatReq msg3<span class="token punctuation">;</span>
                msg3<span class="token punctuation">.</span><span class="token function">set_user_id</span><span class="token punctuation">(</span>from_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                msg3<span class="token punctuation">.</span><span class="token function">add_user_id_list</span><span class="token punctuation">(</span>to_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                msg3<span class="token punctuation">.</span><span class="token function">set_attach_data</span><span class="token punctuation">(</span>attach_data<span class="token punctuation">.</span><span class="token function">GetBuffer</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> attach_data<span class="token punctuation">.</span><span class="token function">GetLength</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                CImPdu pdu2<span class="token punctuation">;</span>
                pdu2<span class="token punctuation">.</span><span class="token function">SetPBMsg</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>msg3<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pdu2<span class="token punctuation">.</span><span class="token function">SetServiceId</span><span class="token punctuation">(</span>SID_BUDDY_LIST<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pdu2<span class="token punctuation">.</span><span class="token function">SetCommandId</span><span class="token punctuation">(</span>CID_BUDDY_LIST_USERS_STATUS_REQUEST<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pdu2<span class="token punctuation">.</span><span class="token function">SetSeqNum</span><span class="token punctuation">(</span>pPdu<span class="token operator">-&gt;</span><span class="token function">GetSeqNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                CRouteServConn<span class="token operator">*</span> route_conn <span class="token operator">=</span> <span class="token function">get_route_serv_conn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>route_conn<span class="token punctuation">)</span>
                <span class="token punctuation">{</span>
                    route_conn<span class="token operator">-&gt;</span><span class="token function">SendPdu</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>pdu2<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span>
    <span class="token punctuation">{</span>
        <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;HandleClientFileRequest, no file server.   &quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileRsp msg2<span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_result_code</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_from_user_id</span><span class="token punctuation">(</span>from_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_to_user_id</span><span class="token punctuation">(</span>to_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_file_name</span><span class="token punctuation">(</span>file_name<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span><span class="token string">&quot;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg2<span class="token punctuation">.</span><span class="token function">set_trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token punctuation">)</span>trans_mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
        CImPdu pdu<span class="token punctuation">;</span>
        pdu<span class="token punctuation">.</span><span class="token function">SetPBMsg</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>msg2<span class="token punctuation">)</span><span class="token punctuation">;</span>
        pdu<span class="token punctuation">.</span><span class="token function">SetServiceId</span><span class="token punctuation">(</span>SID_FILE<span class="token punctuation">)</span><span class="token punctuation">;</span>
        pdu<span class="token punctuation">.</span><span class="token function">SetCommandId</span><span class="token punctuation">(</span>CID_FILE_RESPONSE<span class="token punctuation">)</span><span class="token punctuation">;</span>
        pdu<span class="token punctuation">.</span><span class="token function">SetSeqNum</span><span class="token punctuation">(</span>pPdu<span class="token operator">-&gt;</span><span class="token function">GetSeqNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        pMsgConn<span class="token operator">-&gt;</span><span class="token function">SendPdu</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>pdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#xFF0C;&#x5F88;&#x6709;&#x8BB2;&#x7A76;&#xFF0C;msg_server&#x4F1A;&#x68C0;&#x6D4B;file_server&#x662F;&#x5426;&#x5DF2;&#x7ECF;&#x542F;&#x52A8;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x542F;&#x52A8;&#xFF0C;&#x5219;&#x76F4;&#x63A5;&#x53D1;&#x5305;&#x544A;&#x8BC9;&#x5BA2;&#x6237;&#x7AEF;&#xFF0C;file_server&#x4E0D;&#x5B58;&#x5728;&#x3002;&#x53E6;&#x5916;&#xFF0C;&#x5982;&#x679C;&#x8BE5;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x6A21;&#x5F0F;&#x662F;&#x5728;&#x7EBF;&#x6587;&#x4EF6;&#xFF0C;&#x4F1A;&#x5224;&#x65AD;&#x63A5;&#x6536;&#x6587;&#x4EF6;&#x7684;&#x7528;&#x6237;&#x662F;&#x5426;&#x548C;&#x53D1;&#x9001;&#x7528;&#x6237;&#x5728;&#x540C;&#x4E00;&#x53F0;msg_server&#x4E0A;&#x3002;&#x4E0D;&#x5728;&#x7684;&#x8BDD;&#xFF0C;&#x5219;&#x7ED9;route_server&#x53D1;&#x9001;&#x6D88;&#x606F;&#xFF0C;&#x67E5;&#x627E;&#x8BE5;&#x7528;&#x6237;&#x6240;&#x5728;&#x7684;msg_server&#xFF08;&#x8FD9;&#x4E2A;&#x4E0D;&#x5177;&#x4F53;&#x4ECB;&#x7ECD;&#x4E86;&#xFF0C;&#x540E;&#x9762;&#x5206;&#x6790;route_server&#x4F1A;&#x4E13;&#x95E8;&#x4ECB;&#x7ECD;&#x7684;&#xFF09;&#x3002;&#x5426;&#x5219;&#xFF0C;&#x4F1A;&#x5C06;&#x6587;&#x4EF6;&#x53D1;&#x9001;&#x8BF7;&#x6C42;&#x8F6C;&#x53D1;&#x7ED9;file_server&#xFF0C;&#x5305;&#x7684;&#x547D;&#x4EE4;&#x53F7;&#x662F;CID_OTHER_FILE_TRANSFER_REQ&#x3002;file_server&#x6536;&#x5230;&#x8BE5;&#x8BF7;&#x6C42;&#x540E;&#xFF0C;&#x5904;&#x7406;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileMsgServerConn</span><span class="token operator">::</span><span class="token function">HandlePdu</span><span class="token punctuation">(</span>CImPdu<span class="token operator">*</span> pdu<span class="token punctuation">)</span> <span class="token punctuation">{</span>

     <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;      </span>
    <span class="token keyword">case</span> CID_OTHER_FILE_TRANSFER_REQ<span class="token operator">:</span>
        <span class="token function">_HandleMsgFileTransferReq</span><span class="token punctuation">(</span>pdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span> <span class="token punctuation">;</span>
    <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;        </span>
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileMsgServerConn</span><span class="token operator">::</span><span class="token function">_HandleMsgFileTransferReq</span><span class="token punctuation">(</span>CImPdu<span class="token operator">*</span> pdu<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    IM<span class="token operator">::</span>Server<span class="token operator">::</span>IMFileTransferReq transfer_req<span class="token punctuation">;</span>
    <span class="token function">CHECK_PB_PARSE_MSG</span><span class="token punctuation">(</span>transfer_req<span class="token punctuation">.</span><span class="token function">ParseFromArray</span><span class="token punctuation">(</span>pdu<span class="token operator">-&gt;</span><span class="token function">GetBodyData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> pdu<span class="token operator">-&gt;</span><span class="token function">GetBodyLength</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>


    <span class="token keyword">uint32_t</span> from_id <span class="token operator">=</span> transfer_req<span class="token punctuation">.</span><span class="token function">from_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> to_id <span class="token operator">=</span> transfer_req<span class="token punctuation">.</span><span class="token function">to_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    IM<span class="token operator">::</span>Server<span class="token operator">::</span>IMFileTransferRsp transfer_rsp<span class="token punctuation">;</span>
    transfer_rsp<span class="token punctuation">.</span><span class="token function">set_result_code</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    transfer_rsp<span class="token punctuation">.</span><span class="token function">set_from_user_id</span><span class="token punctuation">(</span>from_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
    transfer_rsp<span class="token punctuation">.</span><span class="token function">set_to_user_id</span><span class="token punctuation">(</span>to_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
    transfer_rsp<span class="token punctuation">.</span><span class="token function">set_file_name</span><span class="token punctuation">(</span>transfer_req<span class="token punctuation">.</span><span class="token function">file_name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    transfer_rsp<span class="token punctuation">.</span><span class="token function">set_file_size</span><span class="token punctuation">(</span>transfer_req<span class="token punctuation">.</span><span class="token function">file_size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    transfer_rsp<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span><span class="token string">&quot;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    transfer_rsp<span class="token punctuation">.</span><span class="token function">set_trans_mode</span><span class="token punctuation">(</span>transfer_req<span class="token punctuation">.</span><span class="token function">trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    transfer_rsp<span class="token punctuation">.</span><span class="token function">set_attach_data</span><span class="token punctuation">(</span>transfer_req<span class="token punctuation">.</span><span class="token function">attach_data</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>


    <span class="token keyword">bool</span> rv <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
    <span class="token keyword">do</span> <span class="token punctuation">{</span>
        std<span class="token operator">::</span>string task_id <span class="token operator">=</span> <span class="token function">GenerateUUID</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>task_id<span class="token punctuation">.</span><span class="token function">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Create task id failed&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;trams_mode=%d, task_id=%s, from_id=%d, to_id=%d, file_name=%s, file_size=%d&quot;</span><span class="token punctuation">,</span> transfer_req<span class="token punctuation">.</span><span class="token function">trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> from_id<span class="token punctuation">,</span> to_id<span class="token punctuation">,</span> transfer_req<span class="token punctuation">.</span><span class="token function">file_name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> transfer_req<span class="token punctuation">.</span><span class="token function">file_size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        BaseTransferTask<span class="token operator">*</span> transfer_task <span class="token operator">=</span> <span class="token class-name">TransferTaskManager</span><span class="token operator">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">NewTransferTask</span><span class="token punctuation">(</span>
                                                                                              transfer_req<span class="token punctuation">.</span><span class="token function">trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                                                                                              task_id<span class="token punctuation">,</span>
                                                                                              from_id<span class="token punctuation">,</span>
                                                                                              to_id<span class="token punctuation">,</span>
                                                                                              transfer_req<span class="token punctuation">.</span><span class="token function">file_name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                                                                                              transfer_req<span class="token punctuation">.</span><span class="token function">file_size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">// &#x521B;&#x5EFA;&#x672A;&#x6210;&#x529F;</span>
            <span class="token comment">// close connection with msg svr</span>
            <span class="token comment">// need_close = true;</span>
            <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Create task failed&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        transfer_rsp<span class="token punctuation">.</span><span class="token function">set_result_code</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        transfer_rsp<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        rv <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        <span class="token comment">// need_seq_no = false;</span>

        <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Create task succeed, task id %s, task type %d, from user %d, to user %d&quot;</span><span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> transfer_req<span class="token punctuation">.</span><span class="token function">trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> from_id<span class="token punctuation">,</span> to_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token operator">::</span><span class="token function">SendMessageLite</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> SID_OTHER<span class="token punctuation">,</span> CID_OTHER_FILE_TRANSFER_RSP<span class="token punctuation">,</span> pdu<span class="token operator">-&gt;</span><span class="token function">GetSeqNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>transfer_rsp<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>rv<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// &#x672A;&#x521B;&#x5EFA;&#x6210;&#x529F;&#xFF0C;&#x5173;&#x95ED;&#x8FDE;&#x63A5;</span>
        <span class="token function">Close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4E0A;&#x8FF0;&#x4EE3;&#x7801;&#x4F1A;&#x4E3A;&#x672C;&#x6B21;&#x4F20;&#x8F93;&#x4EFB;&#x52A1;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x552F;&#x4E00;&#x7684;&#x6807;&#x8BC6;uuid&#x4F5C;&#x4E3A;taskid&#xFF0C;&#x7136;&#x540E;&#x6839;&#x636E;&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#x8FD8;&#x662F;&#x5728;&#x7EBF;&#x6587;&#x4EF6;&#x521B;&#x5EFA;&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x4EFB;&#x52A1;OfflineTransferTask&#x6216;&#x8005;&#x5728;&#x7EBF;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x4EFB;&#x52A1;OnlineTransferTask&#xFF0C;&#x5E76;&#x52A0;&#x5165;&#x4E00;&#x4E2A;&#x4E00;&#x4E2A;&#x6210;&#x5458;&#x53D8;&#x91CF;transfer<em>tasks</em>&#x4E2D;&#x8FDB;&#x884C;&#x7BA1;&#x7406;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp">BaseTransferTask<span class="token operator">*</span> <span class="token class-name">TransferTaskManager</span><span class="token operator">::</span><span class="token function">NewTransferTask</span><span class="token punctuation">(</span><span class="token keyword">uint32_t</span> trans_mode<span class="token punctuation">,</span> <span class="token keyword">const</span> std<span class="token operator">::</span>string<span class="token operator">&amp;</span> task_id<span class="token punctuation">,</span> <span class="token keyword">uint32_t</span> from_user_id<span class="token punctuation">,</span> <span class="token keyword">uint32_t</span> to_user_id<span class="token punctuation">,</span> <span class="token keyword">const</span> std<span class="token operator">::</span>string<span class="token operator">&amp;</span> file_name<span class="token punctuation">,</span> <span class="token keyword">uint32_t</span> file_size<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    BaseTransferTask<span class="token operator">*</span> transfer_task <span class="token operator">=</span> <span class="token constant">NULL</span><span class="token punctuation">;</span>

    TransferTaskMap<span class="token operator">::</span>iterator it <span class="token operator">=</span> transfer_tasks_<span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>it<span class="token operator">==</span>transfer_tasks_<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>trans_mode <span class="token operator">==</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FILE_TYPE_ONLINE<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            transfer_task <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token function">OnlineTransferTask</span><span class="token punctuation">(</span>task_id<span class="token punctuation">,</span> from_user_id<span class="token punctuation">,</span> to_user_id<span class="token punctuation">,</span> file_name<span class="token punctuation">,</span> file_size<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>trans_mode <span class="token operator">==</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FILE_TYPE_OFFLINE<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            transfer_task <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token function">OfflineTransferTask</span><span class="token punctuation">(</span>task_id<span class="token punctuation">,</span> from_user_id<span class="token punctuation">,</span> to_user_id<span class="token punctuation">,</span> file_name<span class="token punctuation">,</span> file_size<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
            <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Invalid trans_mode = %d&quot;</span><span class="token punctuation">,</span> trans_mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            transfer_tasks_<span class="token punctuation">.</span><span class="token function">insert</span><span class="token punctuation">(</span>std<span class="token operator">::</span><span class="token function">make_pair</span><span class="token punctuation">(</span>task_id<span class="token punctuation">,</span> transfer_task<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
        <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Task existed by task_id=%s, why?????&quot;</span><span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> transfer_task<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8FD9;&#x4E2A;map transfer<em>tasks</em>&#x662F;&#x5728;&#x5B9A;&#x65F6;&#x5668;&#x91CC;&#x9762;&#x8FDB;&#x884C;&#x5B9A;&#x671F;&#x5904;&#x7406;&#x7684;&#xFF0C;&#x5904;&#x7406;&#x7684;&#x4F9D;&#x636E;&#x662F;&#x5F53;&#x524D;&#x4EFB;&#x52A1;&#x7684;&#x72B6;&#x6001;&#xFF0C;&#x6BD4;&#x5982;&#x5DF2;&#x7ECF;&#x5B8C;&#x6210;&#x7684;&#x4EFB;&#x52A1;&#x5C31;&#x53EF;&#x4EE5;&#x4ECE;map&#x4E2D;&#x79FB;&#x9664;&#x4E86;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">TransferTaskManager</span><span class="token operator">::</span><span class="token function">OnTimer</span><span class="token punctuation">(</span><span class="token keyword">uint64_t</span> tick<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span>TransferTaskMap<span class="token operator">::</span>iterator it <span class="token operator">=</span> transfer_tasks_<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> it <span class="token operator">!=</span> transfer_tasks_<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        BaseTransferTask<span class="token operator">*</span> task <span class="token operator">=</span> it<span class="token operator">-&gt;</span>second<span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>task <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            transfer_tasks_<span class="token punctuation">.</span><span class="token function">erase</span><span class="token punctuation">(</span>it<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">continue</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>task<span class="token operator">-&gt;</span><span class="token function">state</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">!=</span> kTransferTaskStateWaitingUpload <span class="token operator">&amp;&amp;</span>
            task<span class="token operator">-&gt;</span><span class="token function">state</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> kTransferTaskStateTransferDone<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">long</span> esp <span class="token operator">=</span> <span class="token function">time</span><span class="token punctuation">(</span><span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token operator">-</span> task<span class="token operator">-&gt;</span><span class="token function">create_time</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>esp <span class="token operator">&gt;</span> <span class="token class-name">ConfigUtil</span><span class="token operator">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">GetTaskTimeout</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>task<span class="token operator">-&gt;</span><span class="token function">GetFromConn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    FileClientConn<span class="token operator">*</span> conn <span class="token operator">=</span> <span class="token keyword">reinterpret_cast</span><span class="token operator">&lt;</span>FileClientConn<span class="token operator">*</span><span class="token operator">&gt;</span><span class="token punctuation">(</span>task<span class="token operator">-&gt;</span><span class="token function">GetFromConn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    conn<span class="token operator">-&gt;</span><span class="token function">ClearTransferTask</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>task<span class="token operator">-&gt;</span><span class="token function">GetToConn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    FileClientConn<span class="token operator">*</span> conn <span class="token operator">=</span> <span class="token keyword">reinterpret_cast</span><span class="token operator">&lt;</span>FileClientConn<span class="token operator">*</span><span class="token operator">&gt;</span><span class="token punctuation">(</span>task<span class="token operator">-&gt;</span><span class="token function">GetToConn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    conn<span class="token operator">-&gt;</span><span class="token function">ClearTransferTask</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token keyword">delete</span> task<span class="token punctuation">;</span>
                transfer_tasks_<span class="token punctuation">.</span><span class="token function">erase</span><span class="token punctuation">(</span>it<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">continue</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>

        <span class="token operator">++</span>it<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5B8C;&#x6210;&#x8FD9;&#x4E9B;&#x5DE5;&#x4F5C;&#x4EE5;&#x540E;&#xFF0C;&#x7EC4;&#x88C5;&#x7684;&#x5E94;&#x7B54;&#x5305;&#x547D;&#x4EE4;&#x53F7;&#x662F;CID_OTHER_FILE_TRANSFER_RSP&#xFF0C;&#x56DE;&#x590D;&#x7ED9;msg_server&#x3002;msg_server&#x6536;&#x5230;&#x8BE5;&#x5E94;&#x7B54;&#x5305;&#x540E;&#x5904;&#x7406;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">CFileServConn</span><span class="token operator">::</span><span class="token function">HandlePdu</span><span class="token punctuation">(</span>CImPdu<span class="token operator">*</span> pPdu<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword">switch</span> <span class="token punctuation">(</span>pPdu<span class="token operator">-&gt;</span><span class="token function">GetCommandId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
        <span class="token keyword">case</span> CID_OTHER_FILE_TRANSFER_RSP<span class="token operator">:</span>
            <span class="token function">_HandleFileMsgTransRsp</span><span class="token punctuation">(</span>pPdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801; </span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">CFileServConn</span><span class="token operator">::</span><span class="token function">_HandleFileMsgTransRsp</span><span class="token punctuation">(</span>CImPdu<span class="token operator">*</span> pPdu<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    IM<span class="token operator">::</span>Server<span class="token operator">::</span>IMFileTransferRsp msg<span class="token punctuation">;</span>
    <span class="token function">CHECK_PB_PARSE_MSG</span><span class="token punctuation">(</span>msg<span class="token punctuation">.</span><span class="token function">ParseFromArray</span><span class="token punctuation">(</span>pPdu<span class="token operator">-&gt;</span><span class="token function">GetBodyData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> pPdu<span class="token operator">-&gt;</span><span class="token function">GetBodyLength</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">uint32_t</span> result <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">result_code</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> from_id <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">from_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> to_id <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">to_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    string file_name <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">file_name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> file_size <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">file_size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    string task_id <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> trans_mode <span class="token operator">=</span> msg<span class="token punctuation">.</span><span class="token function">trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    CDbAttachData <span class="token function">attach</span><span class="token punctuation">(</span><span class="token punctuation">(</span>uchar_t<span class="token operator">*</span><span class="token punctuation">)</span>msg<span class="token punctuation">.</span><span class="token function">attach_data</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> msg<span class="token punctuation">.</span><span class="token function">attach_data</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;HandleFileMsgTransRsp, result: %u, from_user_id: %u, to_user_id: %u, file_name: %s, \
        task_id: %s, trans_mode: %u. &quot;</span><span class="token punctuation">,</span> result<span class="token punctuation">,</span> from_id<span class="token punctuation">,</span> to_id<span class="token punctuation">,</span>
        file_name<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> trans_mode<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">const</span> list<span class="token operator">&lt;</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr<span class="token operator">&gt;</span><span class="token operator">*</span> ip_addr_list <span class="token operator">=</span> <span class="token function">GetFileServerIPList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileRsp msg2<span class="token punctuation">;</span>
    msg2<span class="token punctuation">.</span><span class="token function">set_result_code</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
    msg2<span class="token punctuation">.</span><span class="token function">set_from_user_id</span><span class="token punctuation">(</span>from_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
    msg2<span class="token punctuation">.</span><span class="token function">set_to_user_id</span><span class="token punctuation">(</span>to_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
    msg2<span class="token punctuation">.</span><span class="token function">set_file_name</span><span class="token punctuation">(</span>file_name<span class="token punctuation">)</span><span class="token punctuation">;</span>
    msg2<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
    msg2<span class="token punctuation">.</span><span class="token function">set_trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token punctuation">)</span>trans_mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span>list<span class="token operator">&lt;</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr<span class="token operator">&gt;</span><span class="token operator">::</span>const_iterator it <span class="token operator">=</span> ip_addr_list<span class="token operator">-&gt;</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> it <span class="token operator">!=</span> ip_addr_list<span class="token operator">-&gt;</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> it<span class="token operator">++</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr ip_addr_tmp <span class="token operator">=</span> <span class="token operator">*</span>it<span class="token punctuation">;</span>
        IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr<span class="token operator">*</span> ip_addr <span class="token operator">=</span> msg2<span class="token punctuation">.</span><span class="token function">add_ip_addr_list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        ip_addr<span class="token operator">-&gt;</span><span class="token function">set_ip</span><span class="token punctuation">(</span>ip_addr_tmp<span class="token punctuation">.</span><span class="token function">ip</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        ip_addr<span class="token operator">-&gt;</span><span class="token function">set_port</span><span class="token punctuation">(</span>ip_addr_tmp<span class="token punctuation">.</span><span class="token function">port</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    CImPdu pdu<span class="token punctuation">;</span>
    pdu<span class="token punctuation">.</span><span class="token function">SetPBMsg</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>msg2<span class="token punctuation">)</span><span class="token punctuation">;</span>
    pdu<span class="token punctuation">.</span><span class="token function">SetServiceId</span><span class="token punctuation">(</span>SID_FILE<span class="token punctuation">)</span><span class="token punctuation">;</span>
    pdu<span class="token punctuation">.</span><span class="token function">SetCommandId</span><span class="token punctuation">(</span>CID_FILE_RESPONSE<span class="token punctuation">)</span><span class="token punctuation">;</span>
    pdu<span class="token punctuation">.</span><span class="token function">SetSeqNum</span><span class="token punctuation">(</span>pPdu<span class="token operator">-&gt;</span><span class="token function">GetSeqNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> handle <span class="token operator">=</span> attach<span class="token punctuation">.</span><span class="token function">GetHandle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    CMsgConn<span class="token operator">*</span> pFromConn <span class="token operator">=</span> <span class="token class-name">CImUserManager</span><span class="token operator">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">GetMsgConnByHandle</span><span class="token punctuation">(</span>from_id<span class="token punctuation">,</span> handle<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>pFromConn<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        pFromConn<span class="token operator">-&gt;</span><span class="token function">SendPdu</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>pdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span>result <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileNotify msg3<span class="token punctuation">;</span>
        msg3<span class="token punctuation">.</span><span class="token function">set_from_user_id</span><span class="token punctuation">(</span>from_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg3<span class="token punctuation">.</span><span class="token function">set_to_user_id</span><span class="token punctuation">(</span>to_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg3<span class="token punctuation">.</span><span class="token function">set_file_name</span><span class="token punctuation">(</span>file_name<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg3<span class="token punctuation">.</span><span class="token function">set_file_size</span><span class="token punctuation">(</span>file_size<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg3<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg3<span class="token punctuation">.</span><span class="token function">set_trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token punctuation">)</span>trans_mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
        msg3<span class="token punctuation">.</span><span class="token function">set_offline_ready</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span>list<span class="token operator">&lt;</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr<span class="token operator">&gt;</span><span class="token operator">::</span>const_iterator it <span class="token operator">=</span> ip_addr_list<span class="token operator">-&gt;</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> it <span class="token operator">!=</span> ip_addr_list<span class="token operator">-&gt;</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> it<span class="token operator">++</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr ip_addr_tmp <span class="token operator">=</span> <span class="token operator">*</span>it<span class="token punctuation">;</span>
            IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr<span class="token operator">*</span> ip_addr <span class="token operator">=</span> msg3<span class="token punctuation">.</span><span class="token function">add_ip_addr_list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            ip_addr<span class="token operator">-&gt;</span><span class="token function">set_ip</span><span class="token punctuation">(</span>ip_addr_tmp<span class="token punctuation">.</span><span class="token function">ip</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            ip_addr<span class="token operator">-&gt;</span><span class="token function">set_port</span><span class="token punctuation">(</span>ip_addr_tmp<span class="token punctuation">.</span><span class="token function">port</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        CImPdu pdu2<span class="token punctuation">;</span>
        pdu2<span class="token punctuation">.</span><span class="token function">SetPBMsg</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>msg3<span class="token punctuation">)</span><span class="token punctuation">;</span>
        pdu2<span class="token punctuation">.</span><span class="token function">SetServiceId</span><span class="token punctuation">(</span>SID_FILE<span class="token punctuation">)</span><span class="token punctuation">;</span>
        pdu2<span class="token punctuation">.</span><span class="token function">SetCommandId</span><span class="token punctuation">(</span>CID_FILE_NOTIFY<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">//send notify to target user</span>
        CImUser<span class="token operator">*</span> pToUser <span class="token operator">=</span> <span class="token class-name">CImUserManager</span><span class="token operator">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">GetImUserById</span><span class="token punctuation">(</span>to_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>pToUser<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            pToUser<span class="token operator">-&gt;</span><span class="token function">BroadcastPduWithOutMobile</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>pdu2<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">//send to route server</span>
        CRouteServConn<span class="token operator">*</span> pRouteConn <span class="token operator">=</span> <span class="token function">get_route_serv_conn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>pRouteConn<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            pRouteConn<span class="token operator">-&gt;</span><span class="token function">SendPdu</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>pdu2<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>msg_server&#x6536;&#x5230;&#x5305;&#x540E;&#xFF0C;&#x9996;&#x5148;&#x88C5;&#x5305;&#x6570;&#x636E;&#xFF0C;&#x5E76;&#x628A;file_server&#x7684;ip&#x5730;&#x5740;&#x548C;&#x7AEF;&#x53E3;&#x4FE1;&#x606F;&#x5E26;&#x4E0A;&#xFF0C;&#x53D1;&#x7ED9;&#x8BF7;&#x6C42;&#x53D1;&#x6587;&#x4EF6;&#x7684;&#x5BA2;&#x6237;&#x7AEF;&#xFF0C;&#x547D;&#x4EE4;&#x53F7;&#x662F;CID_FILE_RESPONSE&#xFF1B;&#x63A5;&#x7740;&#x67E5;&#x8BE2;&#x901A;&#x77E5;&#x63A5;&#x6536;&#x65B9;&#x6709;&#x4EBA;&#x7ED9;&#x5176;&#x53D1;&#x6587;&#x4EF6;&#xFF08;&#x901A;&#x77E5;&#x65B9;&#x5F0F;&#x4E5F;&#x662F;&#x4E00;&#x6837;&#xFF0C;&#x5982;&#x679C;&#x63A5;&#x6536;&#x65B9;&#x5728;&#x8BE5;msg_server&#x4E0A;&#xFF0C;&#x76F4;&#x63A5;&#x53D1;&#x7ED9;&#x8BE5;&#x7528;&#x6237;&#xFF1B;&#x4E0D;&#x5728;&#x7684;&#x8BDD;&#xFF0C;&#x53D1;&#x7ED9;&#x8DEF;&#x7531;&#x670D;&#x52A1;route_server&#xFF09;&#x3002;&#x5F53;&#x7136;&#x63A5;&#x6536;&#x5230;&#x6587;&#x4EF6;&#x53D1;&#x9001;&#x7684;&#x7AEF;&#x53EA;&#x6709;pc&#x7AEF;&#xFF0C;&#x79FB;&#x52A8;&#x7AEF;&#x4F1A;&#x88AB;&#x8FC7;&#x6EE4;&#x6389;&#x7684;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x79FB;&#x52A8;&#x7AEF;&#x4E0D;&#x4F1A;&#x6536;&#x5230;&#x53D1;&#x9001;&#x6587;&#x4EF6;&#x7684;&#x8BF7;&#x6C42;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x5148;&#x770B;&#x53D1;&#x9001;&#x65B9;pc&#x5BA2;&#x6237;&#x7AEF;&#x6536;&#x5230;&#x5E94;&#x7B54;&#x7684;&#x903B;&#x8F91;&#xFF08;&#x547D;&#x4EE4;&#x53F7;&#x662F;CID_FILE_RESPONSE&#xFF09;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileTransferModule_Impl</span><span class="token operator">::</span><span class="token function">onPacket</span><span class="token punctuation">(</span>imcore<span class="token operator">::</span>TTPBHeader<span class="token operator">&amp;</span> header<span class="token punctuation">,</span> std<span class="token operator">::</span>string<span class="token operator">&amp;</span> pbBody<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword">switch</span> <span class="token punctuation">(</span>header<span class="token punctuation">.</span><span class="token function">getCommandId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
    <span class="token keyword">case</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FileCmdID<span class="token operator">::</span>CID_FILE_RESPONSE<span class="token operator">:</span><span class="token comment">//&#x53D1;&#x9001;&#x201C;&#x6587;&#x4EF6;&#x8BF7;&#x6C42;/&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#x201D;-&#x8FD4;&#x56DE;</span>
        <span class="token function">_sendfileResponse</span><span class="token punctuation">(</span>pbBody<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>    
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileTransferModule_Impl</span><span class="token operator">::</span><span class="token function">_sendfileResponse</span><span class="token punctuation">(</span>IN std<span class="token operator">::</span>string<span class="token operator">&amp;</span> body<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileRsp imFileRsp<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>imFileRsp<span class="token punctuation">.</span><span class="token function">ParseFromString</span><span class="token punctuation">(</span>body<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;parse failed,body:%s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>body<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    UInt32 nResult <span class="token operator">=</span> imFileRsp<span class="token punctuation">.</span><span class="token function">result_code</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>nResult <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;_sendfileResponse result != 0&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        module<span class="token operator">::</span><span class="token function">getFileTransferModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">asynNotifyObserver</span><span class="token punctuation">(</span>module<span class="token operator">::</span>KEY_FILESEVER_UPLOAD_FAILED<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    TransferFileEntity fileEntity<span class="token punctuation">;</span>
    fileEntity<span class="token punctuation">.</span>sTaskID <span class="token operator">=</span> imFileRsp<span class="token punctuation">.</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">assert</span><span class="token punctuation">(</span><span class="token operator">!</span>fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">.</span><span class="token function">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    fileEntity<span class="token punctuation">.</span>sFromID <span class="token operator">=</span> util<span class="token operator">::</span><span class="token function">uint32ToString</span><span class="token punctuation">(</span>imFileRsp<span class="token punctuation">.</span><span class="token function">from_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    fileEntity<span class="token punctuation">.</span>sToID <span class="token operator">=</span> util<span class="token operator">::</span><span class="token function">uint32ToString</span><span class="token punctuation">(</span>imFileRsp<span class="token punctuation">.</span><span class="token function">to_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    fileEntity<span class="token punctuation">.</span>sFileName <span class="token operator">=</span> imFileRsp<span class="token punctuation">.</span><span class="token function">file_name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    fileEntity<span class="token punctuation">.</span><span class="token function">setSaveFilePath</span><span class="token punctuation">(</span>util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sFileName<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//&#x53D1;&#x9001;&#x65B9;&#x6587;&#x4EF6;&#x5730;&#x5740;&#xFF0C;&#x5C31;&#x662F;&#x4FDD;&#x5B58;&#x5730;&#x5740;</span>
    fileEntity<span class="token punctuation">.</span>time <span class="token operator">=</span> <span class="token keyword">static_cast</span><span class="token operator">&lt;</span>UInt32<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token function">time</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> transMode <span class="token operator">=</span> imFileRsp<span class="token punctuation">.</span><span class="token function">trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token operator">::</span>FILE_TYPE_ONLINE <span class="token operator">==</span> transMode<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        fileEntity<span class="token punctuation">.</span>nClientMode <span class="token operator">=</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole<span class="token operator">::</span>CLIENT_REALTIME_SENDER<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token operator">::</span>FILE_TYPE_OFFLINE <span class="token operator">==</span> transMode<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        fileEntity<span class="token punctuation">.</span>nClientMode <span class="token operator">=</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole<span class="token operator">::</span>CLIENT_OFFLINE_UPLOAD<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    fileEntity<span class="token punctuation">.</span>pFileObject <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token function">TransferFile</span><span class="token punctuation">(</span>util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sFileName<span class="token punctuation">)</span><span class="token punctuation">,</span>FALSE<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>pFileObject<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        fileEntity<span class="token punctuation">.</span>nFileSize <span class="token operator">=</span> fileEntity<span class="token punctuation">.</span>pFileObject<span class="token operator">-&gt;</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    UINT32 nIPCount <span class="token operator">=</span> imFileRsp<span class="token punctuation">.</span><span class="token function">ip_addr_list_size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>nIPCount <span class="token operator">&lt;=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">const</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr<span class="token operator">&amp;</span> ipAdd <span class="token operator">=</span> imFileRsp<span class="token punctuation">.</span><span class="token function">ip_addr_list</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    fileEntity<span class="token punctuation">.</span>sIP <span class="token operator">=</span> ipAdd<span class="token punctuation">.</span><span class="token function">ip</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    fileEntity<span class="token punctuation">.</span>nPort <span class="token operator">=</span> ipAdd<span class="token punctuation">.</span><span class="token function">port</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">pushTransferFileEntity</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">)</span><span class="token punctuation">)</span>
        <span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">updateFileInfoBysTaskID</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">LOG__</span><span class="token punctuation">(</span>DEBG<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;FileTransferSevice_Impl::&#x51C6;&#x5907;&#x8FDE;&#x63A5;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x5668; sTaskId = %s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">openFileSocketByTaskId</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5BA2;&#x6237;&#x7AEF;&#x5728;TransferFileEntityManager::getInstance()-&gt;openFileSocketByTaskId(fileEntity.sTaskID);&#x91CC;&#x9762;&#x5B9E;&#x9645;&#x53BB;&#x8FDE;&#x63A5;file_server&#x5E76;&#x5C1D;&#x8BD5;&#x53D1;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">openFileSocketByTaskId</span><span class="token punctuation">(</span>std<span class="token operator">::</span>string<span class="token operator">&amp;</span> taskId<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    m_fileUIThread<span class="token operator">-&gt;</span><span class="token function">openFileSocketByTaskId</span><span class="token punctuation">(</span>taskId<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileTransferUIThread</span><span class="token operator">::</span><span class="token function">openFileSocketByTaskId</span><span class="token punctuation">(</span>std<span class="token operator">::</span>string<span class="token operator">&amp;</span> taskId<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    FileTransferSocket<span class="token operator">*</span> pFileSocket <span class="token operator">=</span> <span class="token function">_findFileSocketByTaskId</span><span class="token punctuation">(</span>taskId<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>pFileSocket<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        pFileSocket <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token function">FileTransferSocket</span><span class="token punctuation">(</span>taskId<span class="token punctuation">)</span><span class="token punctuation">;</span>
        m_lstFileTransSockets<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>pFileSocket<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">assert</span><span class="token punctuation">(</span>m_hWnd<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token operator">::</span><span class="token function">PostMessage</span><span class="token punctuation">(</span>m_hWnd<span class="token punctuation">,</span> WM_FILE_TRANSFER<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>LPARAM<span class="token punctuation">)</span>pFileSocket<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-cpp">LRESULT _stdcall <span class="token class-name">FileTransferUIThread</span><span class="token operator">::</span><span class="token function">_WndProc</span><span class="token punctuation">(</span>HWND hWnd<span class="token punctuation">,</span> UINT message<span class="token punctuation">,</span> WPARAM wparam<span class="token punctuation">,</span> LPARAM lparam<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>WM_FILE_TRANSFER <span class="token operator">==</span> message<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        FileTransferSocket<span class="token operator">*</span> pFileSocket <span class="token operator">=</span> <span class="token punctuation">(</span>FileTransferSocket<span class="token operator">*</span><span class="token punctuation">)</span>lparam<span class="token punctuation">;</span>
        pFileSocket<span class="token operator">-&gt;</span><span class="token function">startFileTransLink</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> <span class="token operator">::</span><span class="token function">DefWindowProc</span><span class="token punctuation">(</span>hWnd<span class="token punctuation">,</span> message<span class="token punctuation">,</span> wparam<span class="token punctuation">,</span> lparam<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-cpp">BOOL <span class="token class-name">FileTransferSocket</span><span class="token operator">::</span><span class="token function">startFileTransLink</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    TransferFileEntity FileInfo<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">getFileInfoByTaskId</span><span class="token punctuation">(</span>m_sTaskId<span class="token punctuation">,</span> FileInfo<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token comment">//&#x5927;&#x4F5B;&#xFF1A;&#x4F7F;&#x7528;msg server &#x4F20;&#x8FC7;&#x6765;&#x7684;IP&#x548C;&#x7AEF;&#x53E3;</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;connect IP=%s,Port=%d&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>FileInfo<span class="token punctuation">.</span>sIP<span class="token punctuation">)</span><span class="token punctuation">,</span> FileInfo<span class="token punctuation">.</span>nPort<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">connect</span><span class="token punctuation">(</span>util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>FileInfo<span class="token punctuation">.</span>sIP<span class="token punctuation">)</span><span class="token punctuation">,</span> FileInfo<span class="token punctuation">.</span>nPort<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//connect(util::stringToCString(module::FILETRANSFER_IP), module::FILETRANSFER_PORT);</span>
        <span class="token keyword">return</span> TRUE<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;can&apos;t find the TaskId&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> FALSE<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x8FD9;&#x91CC;&#x53EA;&#x662F;&#x53BB;&#x8FDE;&#x63A5;file_server&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x8FDE;&#x63A5;&#x6210;&#x529F;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x4F1A;&#x5C1D;&#x8BD5;&#x767B;&#x5F55;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x767B;&#x5F55;file_server&#x7684;&#x547D;&#x4EE4;&#x53F7;&#x662F;CID_FILE_LOGIN_REQ&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileTransferSocket</span><span class="token operator">::</span><span class="token function">onConnectDone</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;FileTransferSocket::onConnected()&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">startHeartbeat</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    TransferFileEntity info<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">getFileInfoByTaskId</span><span class="token punctuation">(</span>m_sTaskId<span class="token punctuation">,</span> info<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;Can&apos;t get the file info,task id:%s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>m_sTaskId<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">//&#x62C9;&#x6A21;&#x5F0F;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#xFF0C;&#x4F20;&#x8F93;taskid&#x3001;token&#x3001;client_mode</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileLoginReq imFileLoginReq<span class="token punctuation">;</span>
    imFileLoginReq<span class="token punctuation">.</span><span class="token function">set_user_id</span><span class="token punctuation">(</span>module<span class="token operator">::</span><span class="token function">getSysConfigModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">userId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imFileLoginReq<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>info<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">;</span>
    imFileLoginReq<span class="token punctuation">.</span><span class="token function">set_file_role</span><span class="token punctuation">(</span><span class="token keyword">static_cast</span><span class="token operator">&lt;</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole<span class="token operator">&gt;</span><span class="token punctuation">(</span>info<span class="token punctuation">.</span>nClientMode<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;IMFileLoginReq,sTaskID:%s,nClientMode:%d&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>info<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">,</span> info<span class="token punctuation">.</span>nClientMode<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//send packet</span>
    <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;IMFileLoginReq,taskId:%s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>info<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">sendPacket</span><span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ServiceID<span class="token operator">::</span>SID_FILE<span class="token punctuation">,</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FileCmdID<span class="token operator">::</span>CID_FILE_LOGIN_REQ<span class="token punctuation">,</span> <span class="token operator">&amp;</span>imFileLoginReq<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">//CImPduClientFileLoginReq pduFileLoginReq(module::getSysConfigModule()-&gt;userID().c_str()</span>
    <span class="token comment">//    , &quot;&quot;, info.sTaskID.c_str(), );</span>
    <span class="token comment">//sendPacket(&amp;pduFileLoginReq);</span>
<span class="token punctuation">}</span>
</code></pre>
<p>file_server&#x6536;&#x5230;&#x8BE5;&#x6570;&#x636E;&#x5305;&#x5904;&#x7406;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileClientConn</span><span class="token operator">::</span><span class="token function">HandlePdu</span><span class="token punctuation">(</span>CImPdu<span class="token operator">*</span> pdu<span class="token punctuation">)</span> <span class="token punctuation">{</span>

    <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
        <span class="token keyword">case</span> CID_FILE_LOGIN_REQ<span class="token operator">:</span>
            <span class="token function">_HandleClientFileLoginReq</span><span class="token punctuation">(</span>pdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileClientConn</span><span class="token operator">::</span><span class="token function">_HandleClientFileLoginReq</span><span class="token punctuation">(</span>CImPdu<span class="token operator">*</span> pdu<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileLoginReq login_req<span class="token punctuation">;</span>
    <span class="token function">CHECK_PB_PARSE_MSG</span><span class="token punctuation">(</span>login_req<span class="token punctuation">.</span><span class="token function">ParseFromArray</span><span class="token punctuation">(</span>pdu<span class="token operator">-&gt;</span><span class="token function">GetBodyData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> pdu<span class="token operator">-&gt;</span><span class="token function">GetBodyLength</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">uint32_t</span> user_id <span class="token operator">=</span> login_req<span class="token punctuation">.</span><span class="token function">user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    string task_id <span class="token operator">=</span> login_req<span class="token punctuation">.</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole mode <span class="token operator">=</span> login_req<span class="token punctuation">.</span><span class="token function">file_role</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Client login, user_id=%d, task_id=%s, file_role=%d&quot;</span><span class="token punctuation">,</span> user_id<span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mode<span class="token punctuation">)</span><span class="token punctuation">;</span>

    BaseTransferTask<span class="token operator">*</span> transfer_task <span class="token operator">=</span> <span class="token constant">NULL</span><span class="token punctuation">;</span>

    <span class="token keyword">bool</span> rv <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
    <span class="token keyword">do</span> <span class="token punctuation">{</span>
        <span class="token comment">// &#x67E5;&#x627E;&#x4EFB;&#x52A1;&#x662F;&#x5426;&#x5B58;&#x5728;</span>
        transfer_task <span class="token operator">=</span> <span class="token class-name">TransferTaskManager</span><span class="token operator">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">FindByTaskID</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>mode <span class="token operator">==</span> CLIENT_OFFLINE_DOWNLOAD<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">// &#x6587;&#x4EF6;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x68C0;&#x67E5;&#x662F;&#x5426;&#x662F;&#x79BB;&#x7EBF;&#x4E0B;&#x8F7D;&#xFF0C;&#x6709;&#x53EF;&#x80FD;&#x662F;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x5668;&#x91CD;&#x542F;</span>
                <span class="token comment">// &#x5C1D;&#x8BD5;&#x4ECE;&#x78C1;&#x76D8;&#x52A0;&#x8F7D;</span>
                transfer_task <span class="token operator">=</span> <span class="token class-name">TransferTaskManager</span><span class="token operator">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">NewTransferTask</span><span class="token punctuation">(</span>task_id<span class="token punctuation">,</span> user_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// &#x9700;&#x8981;&#x518D;&#x6B21;&#x5224;&#x65AD;&#x662F;&#x5426;&#x52A0;&#x8F7D;&#x6210;&#x529F;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Find task id failed, user_id=%u, taks_id=%s, mode=%d&quot;</span><span class="token punctuation">,</span> user_id<span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token keyword">break</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
                <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Can&apos;t find task_id, user_id=%u, taks_id=%s, mode=%d&quot;</span><span class="token punctuation">,</span> user_id<span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">break</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>

        <span class="token comment">// &#x72B6;&#x6001;&#x8F6C;&#x6362;</span>
        rv <span class="token operator">=</span> transfer_task<span class="token operator">-&gt;</span><span class="token function">ChangePullState</span><span class="token punctuation">(</span>user_id<span class="token punctuation">,</span> mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>rv<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">// log();</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
            <span class="token comment">//</span>
        <span class="token punctuation">}</span>

        <span class="token comment">// Ok</span>
        auth_ <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        transfer_task_ <span class="token operator">=</span> transfer_task<span class="token punctuation">;</span>
        user_id_ <span class="token operator">=</span> user_id<span class="token punctuation">;</span>
        <span class="token comment">// &#x8BBE;&#x7F6E;conn</span>
        transfer_task<span class="token operator">-&gt;</span><span class="token function">SetConnByUserID</span><span class="token punctuation">(</span>user_id<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        rv <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileLoginRsp login_rsp<span class="token punctuation">;</span>
    login_rsp<span class="token punctuation">.</span><span class="token function">set_result_code</span><span class="token punctuation">(</span>rv<span class="token operator">?</span><span class="token number">0</span><span class="token operator">:</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    login_rsp<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token operator">::</span><span class="token function">SendMessageLite</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> SID_FILE<span class="token punctuation">,</span> CID_FILE_LOGIN_RES<span class="token punctuation">,</span> pdu<span class="token operator">-&gt;</span><span class="token function">GetSeqNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>login_rsp<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span>rv<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task<span class="token operator">-&gt;</span><span class="token function">GetTransMode</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> FILE_TYPE_ONLINE<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task<span class="token operator">-&gt;</span><span class="token function">state</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> kTransferTaskStateWaitingTransfer<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                CImConn<span class="token operator">*</span> conn <span class="token operator">=</span> transfer_task_<span class="token operator">-&gt;</span><span class="token function">GetToConn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>conn<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token function">_StatesNotify</span><span class="token punctuation">(</span>CLIENT_FILE_PEER_READY<span class="token punctuation">,</span> task_id<span class="token punctuation">,</span> transfer_task_<span class="token operator">-&gt;</span><span class="token function">from_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> conn<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
                    <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;to_conn is close, close me!!!&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token function">Close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token comment">// _StatesNotify(CLIENT_FILE_PEER_READY, task_id, user_id, this);</span>
                <span class="token comment">// transfer_task-&gt;StatesNotify(CLIENT_FILE_PEER_READY, task_id, user_id_);</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task<span class="token operator">-&gt;</span><span class="token function">state</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> kTransferTaskStateWaitingUpload<span class="token punctuation">)</span> <span class="token punctuation">{</span>

                OfflineTransferTask<span class="token operator">*</span> offline <span class="token operator">=</span> <span class="token keyword">reinterpret_cast</span><span class="token operator">&lt;</span>OfflineTransferTask<span class="token operator">*</span><span class="token operator">&gt;</span><span class="token punctuation">(</span>transfer_task<span class="token punctuation">)</span><span class="token punctuation">;</span>

                IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFilePullDataReq pull_data_req<span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_user_id</span><span class="token punctuation">(</span>user_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_trans_mode</span><span class="token punctuation">(</span>FILE_TYPE_OFFLINE<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_offset</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_data_size</span><span class="token punctuation">(</span>offline<span class="token operator">-&gt;</span><span class="token function">GetNextSegmentBlockSize</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

                <span class="token operator">::</span><span class="token function">SendMessageLite</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> SID_FILE<span class="token punctuation">,</span> CID_FILE_PULL_DATA_REQ<span class="token punctuation">,</span> <span class="token operator">&amp;</span>pull_data_req<span class="token punctuation">)</span><span class="token punctuation">;</span>

                <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Pull Data Req&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
        <span class="token function">Close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>file_server&#x5E94;&#x7B54;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x547D;&#x4EE4;&#x53F7;&#x662F;CID_FILE_LOGIN_RES&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x6536;&#x5230;&#x8BE5;&#x5305;&#x540E;&#x5904;&#x7406;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileTransferSocket</span><span class="token operator">::</span><span class="token function">onReceiveData</span><span class="token punctuation">(</span><span class="token keyword">const</span> <span class="token keyword">char</span><span class="token operator">*</span> data<span class="token punctuation">,</span> <span class="token keyword">int32_t</span> size<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    std<span class="token operator">::</span>string pbBody<span class="token punctuation">;</span>
    imcore<span class="token operator">::</span>TTPBHeader pbHeader<span class="token punctuation">;</span> 
    <span class="token keyword">try</span>
    <span class="token punctuation">{</span>
        pbHeader<span class="token punctuation">.</span><span class="token function">unSerialize</span><span class="token punctuation">(</span><span class="token punctuation">(</span>byte<span class="token operator">*</span><span class="token punctuation">)</span>data<span class="token punctuation">,</span> imcore<span class="token operator">::</span>HEADER_LENGTH<span class="token punctuation">)</span><span class="token punctuation">;</span>
        pbBody<span class="token punctuation">.</span><span class="token function">assign</span><span class="token punctuation">(</span>data <span class="token operator">+</span> imcore<span class="token operator">::</span>HEADER_LENGTH<span class="token punctuation">,</span> size <span class="token operator">-</span> imcore<span class="token operator">::</span>HEADER_LENGTH<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>OtherCmdID<span class="token operator">::</span>CID_OTHER_HEARTBEAT <span class="token operator">==</span> pbHeader<span class="token punctuation">.</span><span class="token function">getCommandId</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token operator">&amp;&amp;</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ServiceID<span class="token operator">::</span>SID_OTHER <span class="token operator">==</span> pbHeader<span class="token punctuation">.</span><span class="token function">getModuleId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">catch</span> <span class="token punctuation">(</span>CPduException e<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;onPacket CPduException serviceId:%d,commandId:%d,errCode:%d&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">,</span> e<span class="token punctuation">.</span><span class="token function">GetModuleId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> e<span class="token punctuation">.</span><span class="token function">GetCommandId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> e<span class="token punctuation">.</span><span class="token function">GetErrorCode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;FileTransferSocket onPacket unknown exception&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    UInt16 ncmdid <span class="token operator">=</span> pbHeader<span class="token punctuation">.</span><span class="token function">getCommandId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">switch</span> <span class="token punctuation">(</span>ncmdid<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>     
    <span class="token keyword">case</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FileCmdID<span class="token operator">::</span>CID_FILE_LOGIN_RES<span class="token operator">:</span>
        <span class="token function">_fileLoginResponse</span><span class="token punctuation">(</span>pbBody<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
    <span class="token comment">//&#x65E0;&#x5173;&#x4EE3;&#x7801;&#x7701;&#x7565;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileTransferSocket</span><span class="token operator">::</span><span class="token function">_fileLoginResponse</span><span class="token punctuation">(</span>IN std<span class="token operator">::</span>string<span class="token operator">&amp;</span> body<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileLoginRsp imFileLoginRsp<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>imFileLoginRsp<span class="token punctuation">.</span><span class="token function">ParseFromString</span><span class="token punctuation">(</span>body<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;parse failed,body:%s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>body<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>imFileLoginRsp<span class="token punctuation">.</span><span class="token function">result_code</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;file server login failed! &quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">//&#x6253;&#x5F00;&#x6587;&#x4EF6;</span>
    std<span class="token operator">::</span>string taskId <span class="token operator">=</span> imFileLoginRsp<span class="token punctuation">.</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    TransferFileEntity fileEntity<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">getFileInfoByTaskId</span><span class="token punctuation">(</span>taskId<span class="token punctuation">,</span> fileEntity<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;file server login:can&apos;t find the fileInfo &quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;IMFileLoginRsp, file server login succeed&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//&#x63D0;&#x793A;&#x754C;&#x9762;,&#x754C;&#x9762;&#x4E0A;&#x63D2;&#x5165;&#x8BE5;&#x9879;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole<span class="token operator">::</span>CLIENT_REALTIME_SENDER <span class="token operator">==</span> fileEntity<span class="token punctuation">.</span>nClientMode
        <span class="token operator">||</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole<span class="token operator">::</span>CLIENT_OFFLINE_UPLOAD <span class="token operator">==</span> fileEntity<span class="token punctuation">.</span>nClientMode<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        module<span class="token operator">::</span><span class="token function">getFileTransferModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">asynNotifyObserver</span><span class="token punctuation">(</span>module<span class="token operator">::</span>KEY_FILETRANSFER_SENDFILE<span class="token punctuation">,</span> fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole<span class="token operator">::</span>CLIENT_REALTIME_RECVER <span class="token operator">==</span> fileEntity<span class="token punctuation">.</span>nClientMode
        <span class="token operator">||</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole<span class="token operator">::</span>CLIENT_OFFLINE_DOWNLOAD <span class="token operator">==</span> fileEntity<span class="token punctuation">.</span>nClientMode<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        module<span class="token operator">::</span><span class="token function">getFileTransferModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">asynNotifyObserver</span><span class="token punctuation">(</span>module<span class="token operator">::</span>KEY_FILETRANSFER_REQUEST<span class="token punctuation">,</span> fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p><img src="" alt="&#x70B9;&#x51FB;&#x5E76;&#x62D6;&#x62FD;&#x4EE5;&#x79FB;&#x52A8;"></p>
<p>&#x81F3;&#x6B64;&#xFF0C;&#x4E0D;&#x7BA1;&#x662F;&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#x8FD8;&#x662F;&#x5728;&#x7EBF;&#x6587;&#x4EF6;&#x53D1;&#x9001;&#xFF0C;pc&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x663E;&#x793A;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x8FDB;&#x5EA6;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#xFF1A;</p>
<p><img src="../imgs/tt16.jpg" alt=""><img src="" alt="&#x70B9;&#x51FB;&#x5E76;&#x62D6;&#x62FD;&#x4EE5;&#x79FB;&#x52A8;"></p>
<p>&#x5BF9;&#x4E8E;&#x5728;&#x7EBF;&#x6587;&#x4EF6;&#xFF0C;&#x9700;&#x8981;&#x5BF9;&#x7AEF;&#x540C;&#x610F;&#x63A5;&#x6536;&#x6587;&#x4EF6;&#x7684;&#x4F20;&#x8F93;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x624D;&#x4F1A;&#x8BFB;&#x53D6;&#x6587;&#x4EF6;&#xFF0C;&#x8FD9;&#x4E2A;&#x8FDB;&#x5EA6;&#x6761;&#x624D;&#x4F1A;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x3002;&#x800C;&#x5BF9;&#x4E8E;&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#xFF0C;&#x5E94;&#x8BE5;&#x4F1A;&#x7ACB;&#x9A6C;&#x8BFB;&#x53D6;&#x6587;&#x4EF6;&#x4E0A;&#x4F20;&#x6587;&#x4EF6;&#x6570;&#x636E;&#x5230;&#x670D;&#x52A1;&#x5668;&#x3002;&#x53EF;&#x662F;&#x54EA;&#x91CC;&#x4F1A;&#x89E6;&#x53D1;&#x5BA2;&#x6237;&#x7AEF;&#x8BFB;&#x53D6;&#x6587;&#x4EF6;&#x5E76;&#x53D1;&#x9001;&#x7684;&#x903B;&#x8F91;&#x5462;&#xFF1F;&#x95E8;&#x9053;&#x5728;&#x4E8E;file_server&#x5728;&#x6536;&#x5230;&#x767B;&#x5F55;&#x8BF7;&#x6C42;CID_FILE_LOGIN_REQ&#x540E;&#xFF0C;&#x4E0D;&#x4EC5;&#x4F1A;&#x7ED9;&#x5BA2;&#x6237;&#x7AEF;&#x53D1;&#x9001;&#x767B;&#x5F55;&#x5E94;&#x7B54;&#x6570;&#x636E;&#x5305;CID_FILE_LOGIN_RES&#x3002;&#x8FD8;&#x4F1A;&#x6839;&#x636E;&#x6587;&#x4EF6;&#x7684;&#x4F20;&#x8F93;&#x6A21;&#x5F0F;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#x5219;&#x4F1A;&#x7ED9;&#x5BA2;&#x6237;&#x7AEF;&#x53D1;&#x9001;&#x62C9;&#x53D6;&#x6587;&#x4EF6;&#x7684;&#x6570;&#x636E;&#x5305;CID_FILE_PULL_DATA_REQ&#xFF0C;&#x4EE3;&#x7801;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5728;&#x4E0A;&#x9762;&#x7684;FileClientConn::_HandleClientFileLoginReq(CImPdu* pdu)&#x4E2D;&#x8D34;&#x8FC7;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x518D;&#x8D34;&#x4E00;&#x6B21;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileClientConn</span><span class="token operator">::</span><span class="token function">_HandleClientFileLoginReq</span><span class="token punctuation">(</span>CImPdu<span class="token operator">*</span> pdu<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileLoginReq login_req<span class="token punctuation">;</span>
    <span class="token function">CHECK_PB_PARSE_MSG</span><span class="token punctuation">(</span>login_req<span class="token punctuation">.</span><span class="token function">ParseFromArray</span><span class="token punctuation">(</span>pdu<span class="token operator">-&gt;</span><span class="token function">GetBodyData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> pdu<span class="token operator">-&gt;</span><span class="token function">GetBodyLength</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">uint32_t</span> user_id <span class="token operator">=</span> login_req<span class="token punctuation">.</span><span class="token function">user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    string task_id <span class="token operator">=</span> login_req<span class="token punctuation">.</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole mode <span class="token operator">=</span> login_req<span class="token punctuation">.</span><span class="token function">file_role</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Client login, user_id=%d, task_id=%s, file_role=%d&quot;</span><span class="token punctuation">,</span> user_id<span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mode<span class="token punctuation">)</span><span class="token punctuation">;</span>

    BaseTransferTask<span class="token operator">*</span> transfer_task <span class="token operator">=</span> <span class="token constant">NULL</span><span class="token punctuation">;</span>

    <span class="token keyword">bool</span> rv <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
    <span class="token keyword">do</span> <span class="token punctuation">{</span>
        <span class="token comment">// &#x67E5;&#x627E;&#x4EFB;&#x52A1;&#x662F;&#x5426;&#x5B58;&#x5728;</span>
        transfer_task <span class="token operator">=</span> <span class="token class-name">TransferTaskManager</span><span class="token operator">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">FindByTaskID</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>mode <span class="token operator">==</span> CLIENT_OFFLINE_DOWNLOAD<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">// &#x6587;&#x4EF6;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x68C0;&#x67E5;&#x662F;&#x5426;&#x662F;&#x79BB;&#x7EBF;&#x4E0B;&#x8F7D;&#xFF0C;&#x6709;&#x53EF;&#x80FD;&#x662F;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x5668;&#x91CD;&#x542F;</span>
                <span class="token comment">// &#x5C1D;&#x8BD5;&#x4ECE;&#x78C1;&#x76D8;&#x52A0;&#x8F7D;</span>
                transfer_task <span class="token operator">=</span> <span class="token class-name">TransferTaskManager</span><span class="token operator">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">NewTransferTask</span><span class="token punctuation">(</span>task_id<span class="token punctuation">,</span> user_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// &#x9700;&#x8981;&#x518D;&#x6B21;&#x5224;&#x65AD;&#x662F;&#x5426;&#x52A0;&#x8F7D;&#x6210;&#x529F;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Find task id failed, user_id=%u, taks_id=%s, mode=%d&quot;</span><span class="token punctuation">,</span> user_id<span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token keyword">break</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
                <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Can&apos;t find task_id, user_id=%u, taks_id=%s, mode=%d&quot;</span><span class="token punctuation">,</span> user_id<span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">break</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>

        <span class="token comment">// &#x72B6;&#x6001;&#x8F6C;&#x6362;</span>
        rv <span class="token operator">=</span> transfer_task<span class="token operator">-&gt;</span><span class="token function">ChangePullState</span><span class="token punctuation">(</span>user_id<span class="token punctuation">,</span> mode<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>rv<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">// log();</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
            <span class="token comment">//</span>
        <span class="token punctuation">}</span>

        <span class="token comment">// Ok</span>
        auth_ <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        transfer_task_ <span class="token operator">=</span> transfer_task<span class="token punctuation">;</span>
        user_id_ <span class="token operator">=</span> user_id<span class="token punctuation">;</span>
        <span class="token comment">// &#x8BBE;&#x7F6E;conn</span>
        transfer_task<span class="token operator">-&gt;</span><span class="token function">SetConnByUserID</span><span class="token punctuation">(</span>user_id<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        rv <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileLoginRsp login_rsp<span class="token punctuation">;</span>
    login_rsp<span class="token punctuation">.</span><span class="token function">set_result_code</span><span class="token punctuation">(</span>rv<span class="token operator">?</span><span class="token number">0</span><span class="token operator">:</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    login_rsp<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token operator">::</span><span class="token function">SendMessageLite</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> SID_FILE<span class="token punctuation">,</span> CID_FILE_LOGIN_RES<span class="token punctuation">,</span> pdu<span class="token operator">-&gt;</span><span class="token function">GetSeqNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>login_rsp<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span>rv<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task<span class="token operator">-&gt;</span><span class="token function">GetTransMode</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> FILE_TYPE_ONLINE<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task<span class="token operator">-&gt;</span><span class="token function">state</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> kTransferTaskStateWaitingTransfer<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                CImConn<span class="token operator">*</span> conn <span class="token operator">=</span> transfer_task_<span class="token operator">-&gt;</span><span class="token function">GetToConn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>conn<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token function">_StatesNotify</span><span class="token punctuation">(</span>CLIENT_FILE_PEER_READY<span class="token punctuation">,</span> task_id<span class="token punctuation">,</span> transfer_task_<span class="token operator">-&gt;</span><span class="token function">from_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> conn<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
                    <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;to_conn is close, close me!!!&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token function">Close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token comment">// _StatesNotify(CLIENT_FILE_PEER_READY, task_id, user_id, this);</span>
                <span class="token comment">// transfer_task-&gt;StatesNotify(CLIENT_FILE_PEER_READY, task_id, user_id_);</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task<span class="token operator">-&gt;</span><span class="token function">state</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> kTransferTaskStateWaitingUpload<span class="token punctuation">)</span> <span class="token punctuation">{</span>

                OfflineTransferTask<span class="token operator">*</span> offline <span class="token operator">=</span> <span class="token keyword">reinterpret_cast</span><span class="token operator">&lt;</span>OfflineTransferTask<span class="token operator">*</span><span class="token operator">&gt;</span><span class="token punctuation">(</span>transfer_task<span class="token punctuation">)</span><span class="token punctuation">;</span>

                IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFilePullDataReq pull_data_req<span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_user_id</span><span class="token punctuation">(</span>user_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_trans_mode</span><span class="token punctuation">(</span>FILE_TYPE_OFFLINE<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_offset</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_data_size</span><span class="token punctuation">(</span>offline<span class="token operator">-&gt;</span><span class="token function">GetNextSegmentBlockSize</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

                <span class="token operator">::</span><span class="token function">SendMessageLite</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> SID_FILE<span class="token punctuation">,</span> CID_FILE_PULL_DATA_REQ<span class="token punctuation">,</span> <span class="token operator">&amp;</span>pull_data_req<span class="token punctuation">)</span><span class="token punctuation">;</span>

                <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Pull Data Req&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
        <span class="token function">Close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>pc&#x7AEF;&#x6536;&#x5230;CID_FILE_PULL_DATA_REQ&#x540E;&#xFF0C;&#x8868;&#x793A;&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4E0A;&#x4F20;&#x6587;&#x4EF6;&#x6570;&#x636E;&#x4E86;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">case</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FileCmdID<span class="token operator">::</span>CID_FILE_PULL_DATA_REQ<span class="token operator">:</span><span class="token comment">//&#x53D1;&#x6587;&#x4EF6;</span>
        <span class="token function">_filePullDataReqResponse</span><span class="token punctuation">(</span>pbBody<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileTransferSocket</span><span class="token operator">::</span><span class="token function">_filePullDataReqResponse</span><span class="token punctuation">(</span>IN std<span class="token operator">::</span>string<span class="token operator">&amp;</span> body<span class="token punctuation">)</span><span class="token comment">//&#x53D1;</span>
<span class="token punctuation">{</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFilePullDataReq imFilePullDataReq<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>imFilePullDataReq<span class="token punctuation">.</span><span class="token function">ParseFromString</span><span class="token punctuation">(</span>body<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;parse failed,body:%s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>body<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    UInt32 fileSize <span class="token operator">=</span> imFilePullDataReq<span class="token punctuation">.</span><span class="token function">data_size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    UInt32 fileOffset <span class="token operator">=</span> imFilePullDataReq<span class="token punctuation">.</span><span class="token function">offset</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    std<span class="token operator">::</span>string taskId <span class="token operator">=</span> imFilePullDataReq<span class="token punctuation">.</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    TransferFileEntity fileEntity<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">getFileInfoByTaskId</span><span class="token punctuation">(</span>taskId<span class="token punctuation">,</span> fileEntity<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;PullDataReqResponse: can&apos;t find the fileInfo&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token function">LOG__</span><span class="token punctuation">(</span>DEBG<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;send:taskId=%s,filesize=%d,name=%s,BolckSize=%d&quot;</span><span class="token punctuation">)</span>
        <span class="token punctuation">,</span>util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span>
        <span class="token punctuation">,</span>fileEntity<span class="token punctuation">.</span>nFileSize
        <span class="token punctuation">,</span>fileEntity<span class="token punctuation">.</span><span class="token function">getRealFileName</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">,</span>fileSize<span class="token punctuation">)</span><span class="token punctuation">;</span>
    std<span class="token operator">::</span>string buff<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token keyword">nullptr</span> <span class="token operator">==</span> fileEntity<span class="token punctuation">.</span>pFileObject<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;PullDataReqResponse: file boject Destoryed!&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    fileEntity<span class="token punctuation">.</span>pFileObject<span class="token operator">-&gt;</span><span class="token function">readBlock</span><span class="token punctuation">(</span>fileOffset<span class="token punctuation">,</span> fileSize<span class="token punctuation">,</span> buff<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//&#x8BFB;&#x53D6;&#x672C;&#x5730;&#x6587;&#x4EF6;&#x7684;&#x6570;&#x636E;&#x5757;</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFilePullDataRsp imFilePullDataRsp<span class="token punctuation">;</span><span class="token comment">//todo check</span>
    imFilePullDataRsp<span class="token punctuation">.</span><span class="token function">set_result_code</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imFilePullDataRsp<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>taskId<span class="token punctuation">)</span><span class="token punctuation">;</span>
    imFilePullDataRsp<span class="token punctuation">.</span><span class="token function">set_user_id</span><span class="token punctuation">(</span>util<span class="token operator">::</span><span class="token function">stringToInt32</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>sFromID<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imFilePullDataRsp<span class="token punctuation">.</span><span class="token function">set_offset</span><span class="token punctuation">(</span>fileOffset<span class="token punctuation">)</span><span class="token punctuation">;</span>
    imFilePullDataRsp<span class="token punctuation">.</span><span class="token function">set_file_data</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">void</span><span class="token operator">*</span><span class="token punctuation">)</span>buff<span class="token punctuation">.</span><span class="token function">data</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> fileSize<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">//send packet</span>
    <span class="token function">sendPacket</span><span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ServiceID<span class="token operator">::</span>SID_FILE<span class="token punctuation">,</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FileCmdID<span class="token operator">::</span>CID_FILE_PULL_DATA_RSP
        <span class="token punctuation">,</span> <span class="token operator">&amp;</span>imFilePullDataRsp<span class="token punctuation">)</span><span class="token punctuation">;</span>

    fileEntity<span class="token punctuation">.</span>nProgress <span class="token operator">=</span> fileOffset <span class="token operator">+</span> fileSize<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>nProgress <span class="token operator">&lt;</span> fileEntity<span class="token punctuation">.</span>nFileSize<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token comment">//&#x66F4;&#x65B0;&#x8FDB;&#x5EA6;&#x6761;</span>
        <span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">updateFileInfoBysTaskID</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//&#x4FDD;&#x5B58;&#x5F53;&#x524D;&#x8FDB;&#x5EA6;</span>
        module<span class="token operator">::</span><span class="token function">getFileTransferModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">asynNotifyObserver</span><span class="token punctuation">(</span>module<span class="token operator">::</span>KEY_FILESEVER_UPDATA_PROGRESSBAR
            <span class="token punctuation">,</span> fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span><span class="token comment">//&#x4F20;&#x8F93;&#x5B8C;&#x6210;</span>
    <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>pFileObject<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">delete</span> fileEntity<span class="token punctuation">.</span>pFileObject<span class="token punctuation">;</span>
            fileEntity<span class="token punctuation">.</span>pFileObject <span class="token operator">=</span> <span class="token keyword">nullptr</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        module<span class="token operator">::</span><span class="token function">getFileTransferModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">asynNotifyObserver</span><span class="token punctuation">(</span>module<span class="token operator">::</span>KEY_FILESEVER_PROGRESSBAR_FINISHED
            <span class="token punctuation">,</span> fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">updateFileInfoBysTaskID</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5F53;&#x7136;&#xFF0C;&#x5982;&#x679C;&#x6587;&#x4EF6;&#x6BD4;&#x8F83;&#x5927;&#xFF0C;&#x4E00;&#x6B21;&#x53D1;&#x4E0D;&#x5B8C;&#x4E5F;&#x6CA1;&#x5173;&#x7CFB;&#xFF0C;&#x5728;CID_FILE_PULL_DATA_REQ&#x4E2D;&#x6709;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x7684;&#x504F;&#x79FB;&#x91CF;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x5728;&#x8BFB;&#x53D6;&#x6587;&#x4EF6;&#x548C;&#x5E94;&#x7B54;&#x670D;&#x52A1;&#x5668;&#x65F6;&#x4E5F;&#x5E26;&#x4E0A;&#x8FD9;&#x4E2A;&#x504F;&#x79FB;&#x91CF;fileOffset&#xFF0C;&#x5E94;&#x7B54;&#x7ED9;&#x670D;&#x52A1;&#x5668;&#x7684;&#x5305;&#x662F;CID_FILE_PULL_DATA_RSP&#x3002;file_server&#x6536;&#x5230;&#x5E94;&#x7B54;&#x540E;&#x5904;&#x7406;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileClientConn</span><span class="token operator">::</span><span class="token function">HandlePdu</span><span class="token punctuation">(</span>CImPdu<span class="token operator">*</span> pdu<span class="token punctuation">)</span> <span class="token punctuation">{</span>

            <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
        <span class="token keyword">case</span> CID_FILE_PULL_DATA_RSP<span class="token operator">:</span>
            <span class="token function">_HandleClientFilePullFileRsp</span><span class="token punctuation">(</span> pdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span> <span class="token punctuation">;</span>
                <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>

<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileClientConn</span><span class="token operator">::</span><span class="token function">_HandleClientFilePullFileRsp</span><span class="token punctuation">(</span>CImPdu <span class="token operator">*</span>pdu<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>auth_ <span class="token operator">||</span> <span class="token operator">!</span>transfer_task_<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;auth is false&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">// &#x53EA;&#x6709;rsp</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFilePullDataRsp pull_data_rsp<span class="token punctuation">;</span>
    <span class="token function">CHECK_PB_PARSE_MSG</span><span class="token punctuation">(</span>pull_data_rsp<span class="token punctuation">.</span><span class="token function">ParseFromArray</span><span class="token punctuation">(</span>pdu<span class="token operator">-&gt;</span><span class="token function">GetBodyData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> pdu<span class="token operator">-&gt;</span><span class="token function">GetBodyLength</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">uint32_t</span> user_id <span class="token operator">=</span> pull_data_rsp<span class="token punctuation">.</span><span class="token function">user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    string task_id <span class="token operator">=</span> pull_data_rsp<span class="token punctuation">.</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> offset <span class="token operator">=</span> pull_data_rsp<span class="token punctuation">.</span><span class="token function">offset</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">uint32_t</span> data_size <span class="token operator">=</span> <span class="token keyword">static_cast</span><span class="token operator">&lt;</span><span class="token keyword">uint32_t</span><span class="token operator">&gt;</span><span class="token punctuation">(</span>pull_data_rsp<span class="token punctuation">.</span><span class="token function">file_data</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">const</span> <span class="token keyword">char</span><span class="token operator">*</span> data <span class="token operator">=</span> pull_data_rsp<span class="token punctuation">.</span><span class="token function">file_data</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">data</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">// log(&quot;Recv FilePullFileRsp, user_id=%d, task_id=%s, file_role=%d, offset=%d, datasize=%d&quot;, user_id, task_id.c_str(), mode, offset, datasize);</span>
    <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Recv FilePullFileRsp, task_id=%s, user_id=%u, offset=%u, data_size=%d&quot;</span><span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> user_id<span class="token punctuation">,</span> offset<span class="token punctuation">,</span> data_size<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">int</span> rv <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
    <span class="token keyword">do</span> <span class="token punctuation">{</span>
        <span class="token comment">//</span>
        <span class="token comment">// &#x68C0;&#x67E5;user_id</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>user_id <span class="token operator">!=</span> user_id_<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Received user_id valid, recv_user_id = %d, transfer_task.user_id = %d, user_id_ = %d&quot;</span><span class="token punctuation">,</span> user_id<span class="token punctuation">,</span> transfer_task_<span class="token operator">-&gt;</span><span class="token function">from_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> user_id_<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">// &#x68C0;&#x67E5;task_id</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task_<span class="token operator">-&gt;</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">!=</span> task_id<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Received task_id valid, recv_task_id = %s, this_task_id = %s&quot;</span><span class="token punctuation">,</span> task_id<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> transfer_task_<span class="token operator">-&gt;</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// Close();</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        rv <span class="token operator">=</span> transfer_task_<span class="token operator">-&gt;</span><span class="token function">DoRecvData</span><span class="token punctuation">(</span>user_id<span class="token punctuation">,</span> offset<span class="token punctuation">,</span> data<span class="token punctuation">,</span> data_size<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>rv <span class="token operator">==</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>transfer_task_<span class="token operator">-&gt;</span><span class="token function">GetTransMode</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> FILE_TYPE_ONLINE<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">// &#x5BF9;&#x4E8E;&#x5728;&#x7EBF;&#xFF0C;&#x76F4;&#x63A5;&#x8F6C;&#x53D1;</span>
            OnlineTransferTask<span class="token operator">*</span> online <span class="token operator">=</span> <span class="token keyword">reinterpret_cast</span><span class="token operator">&lt;</span>OnlineTransferTask<span class="token operator">*</span><span class="token operator">&gt;</span><span class="token punctuation">(</span>transfer_task_<span class="token punctuation">)</span><span class="token punctuation">;</span>
            pdu<span class="token operator">-&gt;</span><span class="token function">SetSeqNum</span><span class="token punctuation">(</span>online<span class="token operator">-&gt;</span><span class="token function">GetSeqNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// online-&gt;SetSeqNum(pdu-&gt;GetSeqNum());</span>

            CImConn<span class="token operator">*</span> conn <span class="token operator">=</span> transfer_task_<span class="token operator">-&gt;</span><span class="token function">GetToConn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>conn<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                conn<span class="token operator">-&gt;</span><span class="token function">SendPdu</span><span class="token punctuation">(</span>pdu<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
            <span class="token comment">// &#x79BB;&#x7EBF;</span>
            <span class="token comment">// all packages recved</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>rv <span class="token operator">==</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token function">_StatesNotify</span><span class="token punctuation">(</span>CLIENT_FILE_DONE<span class="token punctuation">,</span> task_id<span class="token punctuation">,</span> user_id<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// Close();</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
                OfflineTransferTask<span class="token operator">*</span> offline <span class="token operator">=</span> <span class="token keyword">reinterpret_cast</span><span class="token operator">&lt;</span>OfflineTransferTask<span class="token operator">*</span><span class="token operator">&gt;</span><span class="token punctuation">(</span>transfer_task_<span class="token punctuation">)</span><span class="token punctuation">;</span>

                IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFilePullDataReq pull_data_req<span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>task_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_user_id</span><span class="token punctuation">(</span>user_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_trans_mode</span><span class="token punctuation">(</span><span class="token keyword">static_cast</span><span class="token operator">&lt;</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token operator">&gt;</span><span class="token punctuation">(</span>offline<span class="token operator">-&gt;</span><span class="token function">GetTransMode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_offset</span><span class="token punctuation">(</span>offline<span class="token operator">-&gt;</span><span class="token function">GetNextOffset</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                pull_data_req<span class="token punctuation">.</span><span class="token function">set_data_size</span><span class="token punctuation">(</span>offline<span class="token operator">-&gt;</span><span class="token function">GetNextSegmentBlockSize</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

                <span class="token operator">::</span><span class="token function">SendMessageLite</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> SID_FILE<span class="token punctuation">,</span> CID_FILE_PULL_DATA_REQ<span class="token punctuation">,</span> <span class="token operator">&amp;</span>pull_data_req<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// log(&quot;size not match&quot;);</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>

    <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span>rv<span class="token operator">!=</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// -1&#xFF0C;&#x51FA;&#x9519;&#x5173;&#x95ED;</span>
        <span class="token comment">//  1, &#x79BB;&#x7EBF;&#x4E0A;&#x4F20;&#x5B8C;&#x6210;</span>
        <span class="token function">Close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5982;&#x679C;&#x662F;&#x5728;&#x7EBF;&#x6587;&#x4EF6;&#xFF0C;&#x5C31;&#x76F4;&#x63A5;&#x8F6C;&#x53D1;&#x542B;&#x6709;&#x6587;&#x4EF6;&#x6570;&#x636E;&#x7684;&#x5305;&#xFF1B;&#x5982;&#x679C;&#x662F;&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#xFF0C;&#x5219;&#x5B58;&#x5165;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x4E0A;&#xFF0C;&#x5373;&#x5199;&#x5165;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">int</span> <span class="token class-name">OfflineTransferTask</span><span class="token operator">::</span><span class="token function">DoRecvData</span><span class="token punctuation">(</span><span class="token keyword">uint32_t</span> user_id<span class="token punctuation">,</span> <span class="token keyword">uint32_t</span> offset<span class="token punctuation">,</span> <span class="token keyword">const</span> <span class="token keyword">char</span><span class="token operator">*</span> data<span class="token punctuation">,</span> <span class="token keyword">uint32_t</span> data_size<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token comment">// &#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#x4E0A;&#x4F20;</span>

    <span class="token keyword">int</span> rv <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>

    <span class="token keyword">do</span> <span class="token punctuation">{</span>
        <span class="token comment">// &#x68C0;&#x67E5;&#x662F;&#x5426;&#x53D1;&#x9001;&#x8005;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">CheckFromUserID</span><span class="token punctuation">(</span>user_id<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;rsp user_id=%d, but sender_id is %d&quot;</span><span class="token punctuation">,</span> user_id<span class="token punctuation">,</span> from_user_id_<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">// &#x68C0;&#x67E5;&#x72B6;&#x6001;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>state_ <span class="token operator">!=</span> kTransferTaskStateWaitingUpload <span class="token operator">&amp;&amp;</span> state_ <span class="token operator">!=</span> kTransferTaskStateUploading<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;state=%d error, need kTransferTaskStateWaitingUpload or kTransferTaskStateUploading&quot;</span><span class="token punctuation">,</span> state_<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">// &#x68C0;&#x67E5;offset&#x662F;&#x5426;&#x6709;&#x6548;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>offset <span class="token operator">!=</span> transfered_idx_<span class="token operator">*</span>SEGMENT_SIZE<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">//if (data_size != GetNextSegmentBlockSize()) {</span>
        <span class="token comment">//    break;</span>
        <span class="token comment">//}</span>
        <span class="token comment">// todo</span>
        <span class="token comment">// &#x68C0;&#x67E5;&#x6587;&#x4EF6;&#x5927;&#x5C0F;</span>

        data_size <span class="token operator">=</span> <span class="token function">GetNextSegmentBlockSize</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;Ready recv data, offset=%d, data_size=%d, segment_size=%d&quot;</span><span class="token punctuation">,</span> offset<span class="token punctuation">,</span> data_size<span class="token punctuation">,</span> sengment_size_<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>state_ <span class="token operator">==</span> kTransferTaskStateWaitingUpload<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>fp_ <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                fp_ <span class="token operator">=</span> <span class="token function">OpenByWrite</span><span class="token punctuation">(</span>task_id_<span class="token punctuation">,</span> to_user_id_<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>fp_ <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token keyword">break</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>

            <span class="token comment">// &#x5199;&#x6587;&#x4EF6;&#x5934;</span>
            OfflineFileHeader file_header<span class="token punctuation">;</span>
            <span class="token function">memset</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>file_header<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>file_header<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            file_header<span class="token punctuation">.</span><span class="token function">set_create_time</span><span class="token punctuation">(</span><span class="token function">time</span><span class="token punctuation">(</span><span class="token constant">NULL</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            file_header<span class="token punctuation">.</span><span class="token function">set_task_id</span><span class="token punctuation">(</span>task_id_<span class="token punctuation">)</span><span class="token punctuation">;</span>
            file_header<span class="token punctuation">.</span><span class="token function">set_from_user_id</span><span class="token punctuation">(</span>from_user_id_<span class="token punctuation">)</span><span class="token punctuation">;</span>
            file_header<span class="token punctuation">.</span><span class="token function">set_to_user_id</span><span class="token punctuation">(</span>to_user_id_<span class="token punctuation">)</span><span class="token punctuation">;</span>
            file_header<span class="token punctuation">.</span><span class="token function">set_file_name</span><span class="token punctuation">(</span><span class="token string">&quot;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            file_header<span class="token punctuation">.</span><span class="token function">set_file_size</span><span class="token punctuation">(</span>file_size_<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">fwrite</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>file_header<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">sizeof</span><span class="token punctuation">(</span>file_header<span class="token punctuation">)</span><span class="token punctuation">,</span> fp_<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">fflush</span><span class="token punctuation">(</span>fp_<span class="token punctuation">)</span><span class="token punctuation">;</span>

            state_ <span class="token operator">=</span> kTransferTaskStateUploading<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">// &#x5B58;&#x50A8;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>fp_ <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">//</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token function">fwrite</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> data_size<span class="token punctuation">,</span> fp_<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">fflush</span><span class="token punctuation">(</span>fp_<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token operator">++</span>transfered_idx_<span class="token punctuation">;</span>
        <span class="token function">SetLastUpdateTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>transfered_idx_ <span class="token operator">==</span> sengment_size_<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            state_ <span class="token operator">=</span> kTransferTaskStateUploadEnd<span class="token punctuation">;</span>
            <span class="token function">fclose</span><span class="token punctuation">(</span>fp_<span class="token punctuation">)</span><span class="token punctuation">;</span>
            fp_ <span class="token operator">=</span> <span class="token constant">NULL</span><span class="token punctuation">;</span>
            rv <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
            rv <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">return</span> rv<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5982;&#x6B64;&#x5FAA;&#x73AF;&#xFF0C;&#x76F4;&#x81F3;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x5B8C;&#x6210;&#x3002;&#x5F53;&#x7136;&#x6587;&#x4EF6;&#x4E0A;&#x4F20;&#x5B8C;&#x6210;&#x540E;file_server&#x4E5F;&#x4F1A;&#x65AD;&#x5F00;&#x4E0E;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x8FDE;&#x63A5;&#x3002;</p>
<p>&#x5230;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x4ECB;&#x7ECD;&#x4E86;&#x53D1;&#x9001;&#x6587;&#x4EF6;&#x65B9;&#x7684;&#x903B;&#x8F91;&#xFF0C;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x770B;&#x770B;&#x63A5;&#x6536;&#x65B9;&#x7684;&#x903B;&#x8F91;&#xFF0C;&#x4E0A;&#x6587;&#x4E2D;&#x4ECB;&#x7ECD;&#x4E86;&#x63A5;&#x6536;&#x65B9;&#x4F1A;&#x6536;&#x5230;&#x63A5;&#x6536;&#x6587;&#x4EF6;&#x7684;&#x901A;&#x77E5;CID_FILE_NOTIFY&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x5904;&#x7406;&#x8FD9;&#x4E2A;&#x547D;&#x4EE4;&#x53F7;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">case</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FileCmdID<span class="token operator">::</span>CID_FILE_NOTIFY<span class="token operator">:</span><span class="token comment">//&#x6536;&#x5230;&#x201C;&#x53D1;&#x9001;&#x6587;&#x4EF6;&#x8BF7;&#x6C42;&#x201D;</span>
    <span class="token function">_fileNotify</span><span class="token punctuation">(</span>pbBody<span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token function">_fileNotify</span><span class="token punctuation">(</span>pbBody<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">void</span> <span class="token class-name">FileTransferModule_Impl</span><span class="token operator">::</span><span class="token function">_fileNotify</span><span class="token punctuation">(</span>IN std<span class="token operator">::</span>string<span class="token operator">&amp;</span> body<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileNotify imFileNotify<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>imFileNotify<span class="token punctuation">.</span><span class="token function">ParseFromString</span><span class="token punctuation">(</span>body<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;parse failed,body:%s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>body<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    TransferFileEntity file<span class="token punctuation">;</span>
    file<span class="token punctuation">.</span>sFileName <span class="token operator">=</span> imFileNotify<span class="token punctuation">.</span><span class="token function">file_name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    file<span class="token punctuation">.</span>sFromID <span class="token operator">=</span> util<span class="token operator">::</span><span class="token function">uint32ToString</span><span class="token punctuation">(</span>imFileNotify<span class="token punctuation">.</span><span class="token function">from_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    file<span class="token punctuation">.</span>sToID <span class="token operator">=</span> util<span class="token operator">::</span><span class="token function">uint32ToString</span><span class="token punctuation">(</span>imFileNotify<span class="token punctuation">.</span><span class="token function">to_user_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    file<span class="token punctuation">.</span>sTaskID <span class="token operator">=</span> imFileNotify<span class="token punctuation">.</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    file<span class="token punctuation">.</span>nFileSize <span class="token operator">=</span> imFileNotify<span class="token punctuation">.</span><span class="token function">file_size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    UINT32 nIPCount <span class="token operator">=</span> imFileNotify<span class="token punctuation">.</span><span class="token function">ip_addr_list_size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>nIPCount <span class="token operator">&lt;=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">const</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>IpAddr<span class="token operator">&amp;</span> ipAdd <span class="token operator">=</span> imFileNotify<span class="token punctuation">.</span><span class="token function">ip_addr_list</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    file<span class="token punctuation">.</span>sIP <span class="token operator">=</span> ipAdd<span class="token punctuation">.</span><span class="token function">ip</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    file<span class="token punctuation">.</span>nPort <span class="token operator">=</span> ipAdd<span class="token punctuation">.</span><span class="token function">port</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">uint32_t</span> transMode <span class="token operator">=</span> imFileNotify<span class="token punctuation">.</span><span class="token function">trans_mode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token operator">::</span>FILE_TYPE_ONLINE <span class="token operator">==</span> transMode<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        file<span class="token punctuation">.</span>nClientMode <span class="token operator">=</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole<span class="token operator">::</span>CLIENT_REALTIME_RECVER<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>TransferFileType<span class="token operator">::</span>FILE_TYPE_OFFLINE <span class="token operator">==</span> transMode<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        file<span class="token punctuation">.</span>nClientMode <span class="token operator">=</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileRole<span class="token operator">::</span>CLIENT_OFFLINE_DOWNLOAD<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    file<span class="token punctuation">.</span>time <span class="token operator">=</span> <span class="token keyword">static_cast</span><span class="token operator">&lt;</span>UInt32<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token function">time</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">pushTransferFileEntity</span><span class="token punctuation">(</span>file<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">LOG__</span><span class="token punctuation">(</span>DEBG<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;FileTransferSevice_Impl::&#x7ED9;&#x4F60;&#x53D1;&#x6587;&#x4EF6; sFileID = %s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token number">1</span> <span class="token operator">==</span> imFileNotify<span class="token punctuation">.</span><span class="token function">offline_ready</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token comment">//TODO&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#x4F20;&#x8F93;&#x7ED3;&#x675F;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">//&#x8FDE;&#x63A5;&#x670D;&#x52A1;&#x5668;</span>
    <span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">openFileSocketByTaskId</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5176;&#x5B9E;&#x4E5F;&#x5C31;&#x662F;&#x63A5;&#x6536;&#x65B9;&#x4F1A;&#x53BB;&#x8FDE;&#x63A5;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x5668;&#x3002;&#x8FDE;&#x63A5;&#x6210;&#x529F;&#x4EE5;&#x540E;&#xFF0C;&#x5728;&#x5BF9;&#x5E94;&#x7684;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x91CC;&#x9762;&#x89E6;&#x53D1;&#x663E;&#x793A;&#x63A5;&#x6536;&#x6587;&#x4EF6;&#x5BF9;&#x8BDD;&#x6846;&#x3002;&#x4F46;&#x662F;&#x6B64;&#x65F6;&#x5B9E;&#x9645;&#x4E0A;&#x8FD8;&#x4E0D;&#x80FD;&#x63A5;&#x6536;&#x6587;&#x4EF6;&#xFF0C;&#x56E0;&#x4E3A;&#x53D1;&#x9001;&#x65B9;&#x53EF;&#x80FD;&#x8FD8;&#x6CA1;&#x51C6;&#x5907;&#x597D;&#x3002;&#x53D1;&#x9001;&#x65B9;&#x8981;&#x51C6;&#x5907;&#x5565;&#x5462;&#xFF1F;&#x524D;&#x9762;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x4ECB;&#x7ECD;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x68B3;&#x7406;&#x4E00;&#x4E0B;&#x4E0A;&#x8FF0;&#x6D41;&#x7A0B;&#xFF1A;</p>
<ol>
<li><p>&#x53D1;&#x9001;&#x65B9;&#x5148;&#x5411;msg_server&#x8BF7;&#x6C42;&#x53D1;&#x9001;&#x6587;&#x4EF6;&#xFF0C;msg_server&#x8F6C;&#x53D1;&#x7ED9;file_server&#xFF1B;</p>
</li>
<li><p>file_server&#x5E94;&#x7B54;msg_server&#x5E76;&#x544A;&#x8BC9;msg_server&#x81EA;&#x5DF1;&#x7684;&#x5730;&#x5740;&#x548C;&#x7AEF;&#x53E3;&#x53F7;&#xFF1B;</p>
</li>
<li><p>msg_server&#x6536;&#x5230;file_server&#x7684;&#x5E94;&#x7B54;&#x540E;&#xFF0C;&#x5148;&#x56DE;&#x590D;&#x53D1;&#x9001;&#x65B9;&#xFF0C;&#x518D;&#x8F6C;&#x53D1;&#x7ED9;&#x63A5;&#x6536;&#x65B9;&#xFF1B;</p>
</li>
<li><p>&#x53D1;&#x9001;&#x65B9;&#x63A5;&#x7740;&#x53D1;&#x9001;&#x767B;&#x5F55;&#x8BF7;&#x6C42;&#x7ED9;file_server&#xFF0C;file_server&#x6536;&#x5230;&#x8BF7;&#x6C42;&#x51B3;&#x5B9A;&#x662F;&#x5426;&#x7ED9;&#x53D1;&#x9001;&#x65B9;&#x53D1;&#x9001;&#x62C9;&#x53D6;&#x6587;&#x4EF6;&#x7684;&#x6570;&#x636E;&#x5305;&#x3002;&#x5982;&#x679C;&#x662F;&#x79BB;&#x7EBF;&#x6587;&#x4EF6;&#xFF0C;&#x5219;&#x4F1A;&#x7ACB;&#x523B;&#x7ED9;&#x53D1;&#x9001;&#x65B9;&#x53D1;&#x9001;&#x62C9;&#x53D6;&#x6587;&#x4EF6;&#x7684;&#x6570;&#x636E;&#x5305;&#xFF1B;&#x5982;&#x679C;&#x662F;&#x5728;&#x7EBF;&#x6587;&#x4EF6;&#xFF0C;&#x5219;&#x9700;&#x8981;&#x7B49;&#x5F85;&#x63A5;&#x6536;&#x65B9;&#x540C;&#x610F;&#x63A5;&#x6536;&#x3002;</p>
</li>
</ol>
<p>&#x6240;&#x4EE5;&#xFF0C;&#x5FC5;&#x987B;&#x8FC7;&#x4E86;&#x6B65;&#x9AA4;4&#xFF0C;&#x4E00;&#x76F4;&#x5230;file_server&#x5E94;&#x7B54;&#x4E86;&#x53D1;&#x9001;&#x65B9;&#x7684;&#x767B;&#x5F55;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x5668;&#x8BF7;&#x6C42;&#x540E;&#xFF0C;&#x53D1;&#x9001;&#x65B9;&#x624D;&#x7B97;&#x51C6;&#x5907;&#x597D;&#x3002;&#x6B64;&#x65F6;&#xFF0C;file_server&#x77E5;&#x9053;&#x53D1;&#x9001;&#x65B9;&#x5DF2;&#x7ECF;&#x51C6;&#x5907;&#x597D;&#x4E86;&#xFF0C;&#x7ED9;&#x63A5;&#x6536;&#x65B9;&#x53D1;&#x9001;&#x6570;&#x636E;&#x5305;CID_FILE_STATE&#x3002;&#x63A5;&#x6536;&#x65B9;&#x6536;&#x5230;&#x8FD9;&#x4E2A;&#x547D;&#x4EE4;&#x53F7;&#x540E;&#xFF1A;</p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">case</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>FileCmdID<span class="token operator">::</span>CID_FILE_STATE<span class="token operator">:</span><span class="token comment">//</span>
        <span class="token function">_fileState</span><span class="token punctuation">(</span>pbBody<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">void</span> <span class="token class-name">FileTransferSocket</span><span class="token operator">::</span><span class="token function">_fileState</span><span class="token punctuation">(</span>IN std<span class="token operator">::</span>string<span class="token operator">&amp;</span> body<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    IM<span class="token operator">::</span>File<span class="token operator">::</span>IMFileState imFileState<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>imFileState<span class="token punctuation">.</span><span class="token function">ParseFromString</span><span class="token punctuation">(</span>body<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;parse failed,body:%s&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> util<span class="token operator">::</span><span class="token function">stringToCString</span><span class="token punctuation">(</span>body<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    UINT32 nfileState <span class="token operator">=</span> imFileState<span class="token punctuation">.</span><span class="token function">state</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    std<span class="token operator">::</span>string taskId <span class="token operator">=</span> imFileState<span class="token punctuation">.</span><span class="token function">task_id</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    TransferFileEntity fileEntity<span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">getFileInfoByTaskId</span><span class="token punctuation">(</span>taskId<span class="token punctuation">,</span> fileEntity<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>ERR<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;fileState:can&apos;t find the fileInfo &quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">switch</span> <span class="token punctuation">(</span>nfileState<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
    <span class="token keyword">case</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileState<span class="token operator">::</span>CLIENT_FILE_PEER_READY<span class="token operator">:</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;fileState--CLIENT_FILE_PEER_READY &quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
    <span class="token keyword">case</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileState<span class="token operator">::</span>CLIENT_FILE_CANCEL <span class="token operator">:</span><span class="token comment">//&#x53D6;&#x6D88;&#x7684;&#x4E86;&#x6587;&#x4EF6;&#x4F20;&#x8F93;</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;fileState--CLIENT_FILE_CANCEL &quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>pFileObject<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token keyword">delete</span> fileEntity<span class="token punctuation">.</span>pFileObject<span class="token punctuation">;</span>
                fileEntity<span class="token punctuation">.</span>pFileObject <span class="token operator">=</span> <span class="token keyword">nullptr</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">updateFileInfoBysTaskID</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">)</span><span class="token punctuation">;</span>
            module<span class="token operator">::</span><span class="token function">getFileTransferModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">asynNotifyObserver</span><span class="token punctuation">(</span>module<span class="token operator">::</span>KEY_FILESEVER_UPLOAD_CANCEL<span class="token punctuation">,</span> fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
    <span class="token keyword">case</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileState<span class="token operator">::</span>CLIENT_FILE_REFUSE<span class="token operator">:</span><span class="token comment">//&#x62D2;&#x7EDD;&#x4E86;&#x6587;&#x4EF6;</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;fileState--CLIENT_FILE_REFUSE &quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>pFileObject<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token keyword">delete</span> fileEntity<span class="token punctuation">.</span>pFileObject<span class="token punctuation">;</span>
                fileEntity<span class="token punctuation">.</span>pFileObject <span class="token operator">=</span> <span class="token keyword">nullptr</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">updateFileInfoBysTaskID</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">)</span><span class="token punctuation">;</span>
            module<span class="token operator">::</span><span class="token function">getFileTransferModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">asynNotifyObserver</span><span class="token punctuation">(</span>module<span class="token operator">::</span>KEY_FILESEVER_UPLOAD_REJECT<span class="token punctuation">,</span> fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
    <span class="token keyword">case</span> IM<span class="token operator">::</span>BaseDefine<span class="token operator">::</span>ClientFileState<span class="token operator">::</span>CLIENT_FILE_DONE<span class="token operator">:</span>
        <span class="token function">LOG__</span><span class="token punctuation">(</span>APP<span class="token punctuation">,</span> <span class="token function">_T</span><span class="token punctuation">(</span><span class="token string">&quot;fileState--CLIENT_FILE_DONE &quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>fileEntity<span class="token punctuation">.</span>pFileObject<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">delete</span> fileEntity<span class="token punctuation">.</span>pFileObject<span class="token punctuation">;</span>
            fileEntity<span class="token punctuation">.</span>pFileObject <span class="token operator">=</span> <span class="token keyword">nullptr</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token class-name">TransferFileEntityManager</span><span class="token operator">::</span><span class="token function">getInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">updateFileInfoBysTaskID</span><span class="token punctuation">(</span>fileEntity<span class="token punctuation">)</span><span class="token punctuation">;</span>
        module<span class="token operator">::</span><span class="token function">getFileTransferModule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-&gt;</span><span class="token function">asynNotifyObserver</span><span class="token punctuation">(</span>module<span class="token operator">::</span>KEY_FILESEVER_PROGRESSBAR_FINISHED<span class="token punctuation">,</span> fileEntity<span class="token punctuation">.</span>sTaskID<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
    <span class="token keyword">default</span><span class="token operator">:</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x540C;&#x7406;&#xFF0C;&#x5BF9;&#x4E8E;&#x63A5;&#x6536;&#x65B9;&#xFF0C;&#x9009;&#x62E9;&#x63A5;&#x6536;&#x8FD8;&#x662F;&#x62D2;&#x7EDD;&#x6587;&#x4EF6;&#x7684;&#x903B;&#x8F91;&#x4E5F;&#x662F;&#x5728;&#x8FD9;&#x91CC;&#x4E00;&#x8D77;&#x5904;&#x7406;&#x7684;&#xFF0C;&#x4E0E;&#x6B64;&#x7C7B;&#x4F3C;&#xFF0C;&#x8FD9;&#x91CC;&#x5C31;&#x4E0D;&#x518D;&#x91CD;&#x590D;&#x53D9;&#x8FF0;&#x4E86;&#x3002;</p>
<p>&#x63A5;&#x6536;&#x65B9;&#x4E0B;&#x8F7D;&#x6587;&#x4EF6;&#x7684;&#x903B;&#x8F91;&#x548C;&#x53D1;&#x9001;&#x65B9;&#x4E0A;&#x4F20;&#x6587;&#x4EF6;&#x7684;&#x903B;&#x8F91;&#x7C7B;&#x4F3C;&#x3002;&#x8FD9;&#x91CC;&#x4E5F;&#x4E0D;&#x5728;&#x63CF;&#x8FF0;&#x4E86;&#x3002;</p>
<p>&#x6700;&#x540E;&#x8BF4;&#x4E00;&#x70B9;&#x6211;&#x7684;&#x5EFA;&#x8BAE;&#xFF0C;teamtalk&#x7684;file_server&#x903B;&#x8F91;&#x3001;&#x4EE5;&#x53CA;&#x4E0E;&#x5BA2;&#x6237;&#x7AEF;&#x8FD8;&#x6709;msg_server&#x7684;&#x903B;&#x8F91;&#x6D41;&#x7A0B;&#x52A0;&#x4E0A;&#x5404;&#x79CD;&#x7EC6;&#x8282;&#x5199;&#x7684;&#x6BD4;&#x8F83;&#x7684;&#x7EC6;&#x817B;&#xFF0C;&#x4EE3;&#x7801;&#x5B9E;&#x73B0;&#x4E0A;&#x4E5F;&#x6BD4;&#x8F83;&#x597D;&#x3002;&#x5F3A;&#x70C8;&#x5EFA;&#x8BAE;&#x597D;&#x597D;&#x5730;&#x9605;&#x8BFB;&#x8FD9;&#x90E8;&#x5206;&#x7684;&#x4EE3;&#x7801;&#x3002;&#x6BD5;&#x7ADF;&#x5F88;&#x591A;&#x4EBA;&#x5728;&#x81EA;&#x5DF1;&#x5B9E;&#x73B0;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x670D;&#x52A1;&#x5668;&#x65F6;&#xFF0C;&#x8FD8;&#x662F;&#x5B58;&#x5728;&#x4E0D;&#x5C11;&#x95EE;&#x9898;&#x7684;&#x3002;</p>
<p>&#x200B;       </p>
<footer class="page-footer"><span class="copyright">&#x5982;&#x9700;&#x4E0B;&#x8F7D;&#x672C;&#x7AD9;&#x5168;&#x90E8;&#x6280;&#x672F;&#x6587;&#x7AE0;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x3010;&#x9AD8;&#x6027;&#x80FD;&#x670D;&#x52A1;&#x5668;&#x5F00;&#x53D1;&#x3011;&#x516C;&#x4F17;&#x53F7;&#x56DE;&#x590D;&#x5173;&#x952E;&#x5B57;&#x201C;&#x6587;&#x7AE0;&#x4E0B;&#x8F7D;&#x201D;&#x5373;&#x53EF;&#x3002;</span><span class="footer-modification">&#x6700;&#x8FD1;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2020-10-04 15:32:55
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
						
					</section>
					
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

				</div>
			</div>
			
		</div>

		
		
		<a href="07服务器端msfs源码分析.html" class="navigation navigation-prev " aria-label="Previous page: 07 服务器端msfs源码分析">
			<i class="fa fa-angle-left"></i>
		</a>
		
		
		<a href="09服务器端route_server源码分析.html" class="navigation navigation-next " aria-label="Next page: 09 服务器端route_server源码分析">
			<i class="fa fa-angle-right"></i>
		</a>
		
		
		
	</div>
	<script>
		var gitbook = gitbook || [];
		gitbook.push(function() {
			gitbook.page.hasChanged({"page":{"title":"08 服务器端file_server源码分析","level":"6.1.8","depth":2,"next":{"title":"09 服务器端route_server源码分析","level":"6.1.9","depth":2,"path":"articles/TeamTalk源码解析/09服务器端route_server源码分析.md","ref":"articles/TeamTalk源码解析/09服务器端route_server源码分析.md","articles":[]},"previous":{"title":"07 服务器端msfs源码分析","level":"6.1.7","depth":2,"path":"articles/TeamTalk源码解析/07服务器端msfs源码分析.md","ref":"articles/TeamTalk源码解析/07服务器端msfs源码分析.md","articles":[]},"dir":"ltr"},"config":{"plugins":["chapter-fold","-lunr","-search","search-pro","splitter","popup","back-to-top-button","hide-element","prism","-highlight","tbfed-pagefooter","code","anchor-navigation-ex","theme-fexa","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"如需下载本站全部技术文章，可以在【高性能服务器开发】公众号回复关键字“文章下载”即可。","modify_label":"最近更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"prism":{},"livereload":{},"splitter":{},"search-pro":{},"popup":{},"theme-fexa":{"search-placeholder":"输入关键字搜索","logo":"./logo.png","favicon":"./favicon.ico"},"code":{"copyButtons":true},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"anchor-navigation-ex":{"showLevel":false,"associatedWithSummary":true,"mode":"float","showGoTop":false,"printLog":false,"multipleH1":true,"float":{"floatIcon":"fa fa-navicon","showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"back-to-top-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"easy_coder","pdf":{"pageBreaksBefore":"/","headerTemplate":null,"paperSize":"a4","margin":{"right":62,"left":62,"top":36,"bottom":36},"fontSize":12,"fontFamily":"Arial","footerTemplate":null,"chapterMark":"pagebreak","pageNumbers":false},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"isbn":"","variables":{},"title":"高性能服务器开发 技术专栏","links":{},"gitbook":"*","description":"","theme-default":{"showLevel":true},"extension":null},"file":{"path":"articles/TeamTalk源码解析/08服务器端file_server源码分析.md","mtime":"2020-10-04T07:32:55.507Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-10-09T15:31:57.905Z"},"basePath":"../..","book":{"language":""}});
		});
	</script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-fexa/fexa.js"></script>
        
    

    </body>
</html>

